Skip to content

Commit 1a3a435

Browse files
Randall FlaggRandall Flagg
authored andcommitted
Fixed some warnings and improved the tests
Fixed warnings
1 parent ac9348a commit 1a3a435

2 files changed

Lines changed: 19 additions & 30 deletions

File tree

src/ColumnizerLib.UnitTests/ColumnTests.cs

Lines changed: 17 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
using LogExpert;
1+
using LogExpert;
2+
23
using NUnit.Framework;
4+
35
using System;
46
using System.Text;
57

@@ -9,44 +11,30 @@ namespace ColumnizerLib.UnitTests;
911
public class ColumnTests
1012
{
1113
[Test]
12-
public void Column_LineCutOf()
14+
public void Column_LineCutOff ()
1315
{
14-
Column column = new();
15-
16-
StringBuilder builder = new();
16+
var expectedFullValue = new StringBuilder().Append('6', 4675).Append("1234").ToString();
17+
var expectedDisplayValue = expectedFullValue[..4675] + "..."; // Using substring shorthand
1718

18-
for (var i = 0; i < 4675; i++)
19+
Column column = new()
1920
{
20-
builder.Append("6");
21-
}
22-
23-
var expected = builder + "...";
24-
builder.Append("1234");
25-
26-
column.FullValue = builder.ToString();
21+
FullValue = expectedFullValue
22+
};
2723

28-
Assert.That(column.DisplayValue, Is.EqualTo(expected));
29-
Assert.That(column.FullValue, Is.EqualTo(builder.ToString()));
24+
Assert.That(column.DisplayValue, Is.EqualTo(expectedDisplayValue));
25+
Assert.That(column.FullValue, Is.EqualTo(expectedFullValue));
3026
}
3127

3228
[Test]
33-
public void Column_NoLineCutOf()
29+
public void Column_NoLineCutOff ()
3430
{
35-
Column column = new();
36-
37-
StringBuilder builder = new();
38-
39-
for (var i = 0; i < 4675; i++)
31+
var expected = new StringBuilder().Append('6', 4675).ToString();
32+
Column column = new()
4033
{
41-
builder.Append("6");
42-
}
43-
44-
var expected = builder.ToString();
45-
46-
column.FullValue = expected;
34+
FullValue = expected
35+
};
4736

48-
Assert.That(column.DisplayValue, Is.EqualTo(expected));
49-
Assert.That(column.FullValue, Is.EqualTo(expected));
37+
Assert.That(column.DisplayValue, Is.EqualTo(column.FullValue));
5038
}
5139

5240
[Test]

src/LogExpert.Core/Classes/Bookmark/BookmarkExporter.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,12 @@ public static void ExportBookmarkList (SortedList<int, Entities.Bookmark> bookma
1717
FileStream fs = new(fileName, FileMode.Create, FileAccess.Write);
1818
StreamWriter writer = new(fs);
1919
writer.WriteLine("Log file name;Line number;Comment");
20-
foreach (Entities.Bookmark bookmark in bookmarkList.Values)
20+
foreach (var bookmark in bookmarkList.Values)
2121
{
2222
var line = $"{logfileName};{bookmark.LineNum};{bookmark.Text.Replace(replacementForNewLine, @"\" + replacementForNewLine, StringComparison.OrdinalIgnoreCase).Replace("\r\n", replacementForNewLine, StringComparison.OrdinalIgnoreCase)}";
2323
writer.WriteLine(line);
2424
}
25+
2526
writer.Close();
2627
fs.Close();
2728
}

0 commit comments

Comments
 (0)