1
// ****************************************************************
2
// This is free software licensed under the NUnit license. You may
3
// obtain a copy of the license at http://nunit.org
4
// ****************************************************************
6
using System.Collections.Generic;
9
namespace NUnit.UiException.Tests
12
public class TestDefaultTextManager
14
private DefaultTextManager _textBlocks;
19
_textBlocks = new DefaultTextManager();
23
public void Test_Default()
25
Assert.That(_textBlocks.Text, Is.EqualTo(""));
26
Assert.That(_textBlocks.LineCount, Is.EqualTo(0));
27
Assert.That(_textBlocks.MaxLength, Is.EqualTo(0));
33
public void Test_CodeBlockCollection()
37
Assert.That(_textBlocks.LineCount, Is.EqualTo(0));
39
_textBlocks.Text = "01\r\n02\r\n03\r\n";
41
Assert.That(_textBlocks.Text, Is.EqualTo("01\r\n02\r\n03\r\n"));
42
Assert.That(_textBlocks.LineCount, Is.EqualTo(3));
43
Assert.That(_textBlocks.GetTextAt(0), Is.EqualTo("01"));
44
Assert.That(_textBlocks.GetTextAt(1), Is.EqualTo("02"));
45
Assert.That(_textBlocks.GetTextAt(2), Is.EqualTo("03"));
47
_textBlocks.Text = "01";
48
Assert.That(_textBlocks.LineCount, Is.EqualTo(1));
49
Assert.That(_textBlocks.GetTextAt(0), Is.EqualTo("01"));
51
_textBlocks.Text = "01\r\n02";
52
Assert.That(_textBlocks.LineCount, Is.EqualTo(2));
53
Assert.That(_textBlocks.GetTextAt(0), Is.EqualTo("01"));
54
Assert.That(_textBlocks.GetTextAt(1), Is.EqualTo("02"));
56
lst = new List<string>();
57
foreach (string line in _textBlocks)
59
Assert.That(lst.Count, Is.EqualTo(2));
60
Assert.That(lst[0], Is.EqualTo(_textBlocks.GetTextAt(0)));
61
Assert.That(lst[1], Is.EqualTo(_textBlocks.GetTextAt(1)));
63
_textBlocks.Text = null;
64
Assert.That(_textBlocks.Text, Is.EqualTo(""));
70
public void Test_MaxLength()
72
_textBlocks.Text = null;
73
Assert.That(_textBlocks.MaxLength, Is.EqualTo(0));
75
_textBlocks.Text = "a\r\nabc\r\nab";
76
Assert.That(_textBlocks.MaxLength, Is.EqualTo(3));
78
_textBlocks.Text = "a\r\nab\r\nabc";
79
Assert.That(_textBlocks.MaxLength, Is.EqualTo(3));
1
// ****************************************************************
2
// This is free software licensed under the NUnit license. You may
3
// obtain a copy of the license at http://nunit.org
4
// ****************************************************************
6
using System.Collections.Generic;
9
namespace NUnit.UiException.Tests
12
public class TestDefaultTextManager
14
private DefaultTextManager _textBlocks;
19
_textBlocks = new DefaultTextManager();
23
public void Test_Default()
25
Assert.That(_textBlocks.Text, Is.EqualTo(""));
26
Assert.That(_textBlocks.LineCount, Is.EqualTo(0));
27
Assert.That(_textBlocks.MaxLength, Is.EqualTo(0));
33
public void Test_CodeBlockCollection()
37
Assert.That(_textBlocks.LineCount, Is.EqualTo(0));
39
_textBlocks.Text = "01\r\n02\r\n03\r\n";
41
Assert.That(_textBlocks.Text, Is.EqualTo("01\r\n02\r\n03\r\n"));
42
Assert.That(_textBlocks.LineCount, Is.EqualTo(3));
43
Assert.That(_textBlocks.GetTextAt(0), Is.EqualTo("01"));
44
Assert.That(_textBlocks.GetTextAt(1), Is.EqualTo("02"));
45
Assert.That(_textBlocks.GetTextAt(2), Is.EqualTo("03"));
47
_textBlocks.Text = "01";
48
Assert.That(_textBlocks.LineCount, Is.EqualTo(1));
49
Assert.That(_textBlocks.GetTextAt(0), Is.EqualTo("01"));
51
_textBlocks.Text = "01\r\n02";
52
Assert.That(_textBlocks.LineCount, Is.EqualTo(2));
53
Assert.That(_textBlocks.GetTextAt(0), Is.EqualTo("01"));
54
Assert.That(_textBlocks.GetTextAt(1), Is.EqualTo("02"));
56
lst = new List<string>();
57
foreach (string line in _textBlocks)
59
Assert.That(lst.Count, Is.EqualTo(2));
60
Assert.That(lst[0], Is.EqualTo(_textBlocks.GetTextAt(0)));
61
Assert.That(lst[1], Is.EqualTo(_textBlocks.GetTextAt(1)));
63
_textBlocks.Text = null;
64
Assert.That(_textBlocks.Text, Is.EqualTo(""));
70
public void Test_MaxLength()
72
_textBlocks.Text = null;
73
Assert.That(_textBlocks.MaxLength, Is.EqualTo(0));
75
_textBlocks.Text = "a\r\nabc\r\nab";
76
Assert.That(_textBlocks.MaxLength, Is.EqualTo(3));
78
_textBlocks.Text = "a\r\nab\r\nabc";
79
Assert.That(_textBlocks.MaxLength, Is.EqualTo(3));