TextWrapperTests ClassDelta Engine Documentation
Inheritance Hierarchy

System Object
  DeltaEngine.Platforms TestWithMocksOrVisually
    DeltaEngine.Rendering2D.Fonts.Tests TextWrapperTests

Namespace: DeltaEngine.Rendering2D.Fonts.Tests
Assembly: DeltaEngine.Rendering2D.Fonts.Tests (in DeltaEngine.Rendering2D.Fonts.Tests.dll) Version: 1.1.1.0 (1.1.1)
Syntax

public class TextWrapperTests : TestWithMocksOrVisually

The TextWrapperTests type exposes the following members.

Constructors

  NameDescription
Public methodTextWrapperTests
Initializes a new instance of the TextWrapperTests class
Top
Methods

  NameDescription
Protected methodAdvanceTimeAndUpdateEntities (Inherited from TestWithMocksOrVisually.)
Public methodClipTextHeight
Public methodClipTextWidth
Public methodEmptyText
Public methodFontDoesNotFitInTooSmallArea
Public methodGetLines
Public methodGetLinesWithNoSpaceLetters
Public methodInit
Public methodInitializeResolver (Inherited from TestWithMocksOrVisually.)
Protected methodRegisterMock T  (Inherited from TestWithMocksOrVisually.)
Protected methodResolve T  (Inherited from TestWithMocksOrVisually.)
Protected methodRunAfterFirstFrame (Inherited from TestWithMocksOrVisually.)
Public methodRunTestAndDisposeResolverWhenDone (Inherited from TestWithMocksOrVisually.)
Top
Properties

  NameDescription
Protected propertyIsMockResolver (Inherited from TestWithMocksOrVisually.)
Top
Examples

[Test]
public void EmptyText()
{
    var lines = textWrapper.SplitTextIntoLines("", new Size(100, fontDescription.PixelLineHeight), true);
    Assert.AreEqual(0, lines.Count);
}
[Test]
public void FontDoesNotFitInTooSmallArea()
{
    var lines = textWrapper.SplitTextIntoLines(ThreeLineText,
        new Size(70, fontDescription.PixelLineHeight / 2.0f), true);
    Assert.AreEqual(0, lines.Count);
}
[Test]
public void GetLines()
{
    var lines = textWrapper.SplitTextIntoLines(ThreeLineText,
        new Size(70, fontDescription.PixelLineHeight * 3), true);
    Assert.AreEqual(3, lines.Count);
    Assert.AreEqual(Spaces, new string(lines[0].ToArray()));
    Assert.AreEqual(Spaces, new string(lines[1].ToArray()));
    Assert.AreEqual(Spaces, new string(lines[2].ToArray()));
}
[Test]
public void GetLinesWithNoSpaceLetters()
{
    var lines = textWrapper.SplitTextIntoLines("aaaa aaaaa aaa!",
        new Size(70, fontDescription.PixelLineHeight * 3), true);
    Assert.AreEqual(2, lines.Count);
}
[Test]
public void ClipTextHeight()
{
    var lines = textWrapper.SplitTextIntoLines(ThreeLineText,
        new Size(60, fontDescription.PixelLineHeight * 2), true);
    Assert.AreEqual(2, lines.Count);
    Assert.AreEqual(Spaces, new string(lines[0].ToArray()));
    Assert.AreEqual(Spaces, new string(lines[1].ToArray()));
}
[Test]
public void ClipTextWidth()
{
    var lines = textWrapper.SplitTextIntoLines(ThreeLineText,
        new Size(10, fontDescription.PixelLineHeight * 6), true);
    Assert.AreEqual(6, lines.Count);
    Assert.AreEqual("  ", new string(lines[0].ToArray()));
    Assert.AreEqual(" ", new string(lines[1].ToArray()));
    Assert.AreEqual("  ", new string(lines[2].ToArray()));
    Assert.AreEqual(" ", new string(lines[3].ToArray()));
    Assert.AreEqual("  ", new string(lines[4].ToArray()));
    Assert.AreEqual(" ", new string(lines[5].ToArray()));
}
See Also