forked from LogExperts/LogExpert
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathColumnTests.cs
More file actions
72 lines (57 loc) · 1.92 KB
/
ColumnTests.cs
File metadata and controls
72 lines (57 loc) · 1.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
using LogExpert;
using NUnit.Framework;
using System;
using System.Text;
namespace ColumnizerLib.UnitTests;
[TestFixture]
public class ColumnTests
{
[Test]
public void Column_LineCutOff ()
{
var expectedFullValue = new StringBuilder().Append('6', 4675).Append("1234").ToString();
var expectedDisplayValue = expectedFullValue[..4675] + "..."; // Using substring shorthand
Column column = new()
{
FullValue = expectedFullValue
};
Assert.That(column.DisplayValue, Is.EqualTo(expectedDisplayValue));
Assert.That(column.FullValue, Is.EqualTo(expectedFullValue));
}
[Test]
public void Column_NoLineCutOff ()
{
var expected = new StringBuilder().Append('6', 4675).ToString();
Column column = new()
{
FullValue = expected
};
Assert.That(column.DisplayValue, Is.EqualTo(column.FullValue));
}
[Test]
public void Column_NullCharReplacement()
{
Column column = new();
column.FullValue = "asdf\0";
//Switch between the different implementation for the windows versions
//Not that great solution but currently I'm out of ideas, I know that currently
//only one implementation depending on the windows version is executed
if (Environment.Version >= Version.Parse("6.2"))
{
Assert.That(column.DisplayValue, Is.EqualTo("asdf␀"));
}
else
{
Assert.That(column.DisplayValue, Is.EqualTo("asdf "));
}
Assert.That(column.FullValue, Is.EqualTo("asdf\0"));
}
[Test]
public void Column_TabReplacement()
{
Column column = new();
column.FullValue = "asdf\t";
Assert.That(column.DisplayValue, Is.EqualTo("asdf "));
Assert.That(column.FullValue, Is.EqualTo("asdf\t"));
}
}