Skip to content

Commit 0bc9112

Browse files
committed
Unit testing update
1 parent e4ad3fe commit 0bc9112

File tree

3 files changed

+78
-78
lines changed

3 files changed

+78
-78
lines changed

test/Sources/ReportSourceTest.cs

Lines changed: 64 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -6,46 +6,46 @@ namespace BlackDigital.Report.Tests.Sources
66
public class ReportSourceTest
77
{
88
[Fact]
9-
public void SingleReportValue()
9+
public async void SingleReportValue()
1010
{
1111
var value = new SingleReportSource();
1212
value.Load("Hello World");
1313

14-
Assert.Null(value.GetValue());
14+
Assert.Null(await value.GetValueAsync());
1515

16-
Assert.True(value.NextRow());
17-
Assert.True(value.NextColumn());
16+
Assert.True(await value.NextRowAsync());
17+
Assert.True(await value.NextColumnAsync());
1818

19-
Assert.Equal("Hello World", value.GetValue());
19+
Assert.Equal("Hello World", await value.GetValueAsync());
2020

21-
Assert.False(value.NextColumn());
22-
Assert.Null(value.GetValue());
21+
Assert.False(await value.NextColumnAsync());
22+
Assert.Null(await value.GetValueAsync());
2323

24-
Assert.False(value.NextRow());
25-
Assert.Null(value.GetValue());
24+
Assert.False(await value.NextRowAsync());
25+
Assert.Null(await value.GetValueAsync());
2626
}
2727

2828
[Fact]
29-
public void SingleReportValueWithNull()
29+
public async void SingleReportValueWithNull()
3030
{
3131
var value = new SingleReportSource();
3232

33-
Assert.Null(value.GetValue());
33+
Assert.Null(await value.GetValueAsync());
3434

35-
Assert.True(value.NextRow());
36-
Assert.True(value.NextColumn());
35+
Assert.True(await value.NextRowAsync());
36+
Assert.True(await value.NextColumnAsync());
3737

38-
Assert.Null(value.GetValue());
38+
Assert.Null(await value.GetValueAsync());
3939

40-
Assert.False(value.NextColumn());
41-
Assert.Null(value.GetValue());
40+
Assert.False(await value.NextColumnAsync());
41+
Assert.Null(await value.GetValueAsync());
4242

43-
Assert.False(value.NextRow());
44-
Assert.Null(value.GetValue());
43+
Assert.False(await value.NextRowAsync());
44+
Assert.Null(await value.GetValueAsync());
4545
}
4646

4747
[Fact]
48-
public void EnumerableReportValue()
48+
public async void EnumerableReportValue()
4949
{
5050
var value = new EnumerableReportSource();
5151

@@ -55,36 +55,36 @@ public void EnumerableReportValue()
5555
new[] { "Hello2", "World2" }
5656
});
5757

58-
Assert.Null(value.GetValue());
58+
Assert.Null(await value.GetValueAsync());
5959

60-
Assert.True(value.NextRow());
61-
Assert.True(value.NextColumn());
60+
Assert.True(await value.NextRowAsync());
61+
Assert.True(await value.NextColumnAsync());
6262

63-
Assert.Equal("Hello", value.GetValue());
63+
Assert.Equal("Hello", await value.GetValueAsync());
6464

65-
Assert.True(value.NextColumn());
66-
Assert.Equal("World", value.GetValue());
65+
Assert.True(await value.NextColumnAsync());
66+
Assert.Equal("World", await value.GetValueAsync());
6767

68-
Assert.False(value.NextColumn());
69-
Assert.Null(value.GetValue());
68+
Assert.False(await value.NextColumnAsync());
69+
Assert.Null(await value.GetValueAsync());
7070

71-
Assert.True(value.NextRow());
72-
Assert.Null(value.GetValue());
71+
Assert.True(await value.NextRowAsync());
72+
Assert.Null(await value.GetValueAsync());
7373

74-
Assert.True(value.NextColumn());
75-
Assert.Equal("Hello2", value.GetValue());
74+
Assert.True(await value.NextColumnAsync());
75+
Assert.Equal("Hello2", await value.GetValueAsync());
7676

77-
Assert.True(value.NextColumn());
78-
Assert.Equal("World2", value.GetValue());
77+
Assert.True(await value.NextColumnAsync());
78+
Assert.Equal("World2", await value.GetValueAsync());
7979

80-
Assert.False(value.NextColumn());
81-
Assert.False(value.NextRow());
80+
Assert.False(await value.NextColumnAsync());
81+
Assert.False(await value.NextRowAsync());
8282

83-
Assert.Null(value.GetValue());
83+
Assert.Null(await value.GetValueAsync());
8484
}
8585

8686
[Fact]
87-
public void ModelReportSource()
87+
public async void ModelReportSource()
8888
{
8989
var value = new ModelReportSource<SimpleModel>();
9090

@@ -94,36 +94,36 @@ public void ModelReportSource()
9494
new SimpleModel("World", 2)
9595
});
9696

97-
Assert.Null(value.GetValue());
97+
Assert.Null(await value.GetValueAsync());
9898

99-
Assert.True(value.NextRow());
100-
Assert.True(value.NextColumn());
99+
Assert.True(await value.NextRowAsync());
100+
Assert.True(await value.NextColumnAsync());
101101

102-
Assert.Equal("Hello", value.GetValue());
102+
Assert.Equal("Hello", await value.GetValueAsync());
103103

104-
Assert.True(value.NextColumn());
105-
Assert.Equal(1d, value.GetValue());
104+
Assert.True(await value.NextColumnAsync());
105+
Assert.Equal(1d, await value.GetValueAsync());
106106

107-
Assert.False(value.NextColumn());
108-
Assert.Null(value.GetValue());
107+
Assert.False(await value.NextColumnAsync());
108+
Assert.Null(await value.GetValueAsync());
109109

110-
Assert.True(value.NextRow());
111-
Assert.Null(value.GetValue());
110+
Assert.True(await value.NextRowAsync());
111+
Assert.Null(await value.GetValueAsync());
112112

113-
Assert.True(value.NextColumn());
114-
Assert.Equal("World", value.GetValue());
113+
Assert.True(await value.NextColumnAsync());
114+
Assert.Equal("World", await value.GetValueAsync());
115115

116-
Assert.True(value.NextColumn());
117-
Assert.Equal(2d, value.GetValue());
116+
Assert.True(await value.NextColumnAsync());
117+
Assert.Equal(2d, await value.GetValueAsync());
118118

119-
Assert.False(value.NextColumn());
120-
Assert.False(value.NextRow());
119+
Assert.False(await value.NextColumnAsync());
120+
Assert.False(await value.NextRowAsync());
121121

122-
Assert.Null(value.GetValue());
122+
Assert.Null(await value.GetValueAsync());
123123
}
124124

125125
[Fact]
126-
public void ListReportSource()
126+
public async void ListReportSource()
127127
{
128128
var list = new List<object>
129129
{
@@ -133,20 +133,20 @@ public void ListReportSource()
133133

134134
var value = new ListReportSource(list);
135135

136-
Assert.Null(value.GetValue());
136+
Assert.Null(await value.GetValueAsync());
137137

138-
Assert.True(value.NextRow());
139-
Assert.True(value.NextColumn());
138+
Assert.True(await value.NextRowAsync());
139+
Assert.True(await value.NextColumnAsync());
140140

141-
Assert.Equal("Hello", value.GetValue());
141+
Assert.Equal("Hello", await value.GetValueAsync());
142142

143-
Assert.True(value.NextColumn());
144-
Assert.Equal("World", value.GetValue());
143+
Assert.True(await value.NextColumnAsync());
144+
Assert.Equal("World", await value.GetValueAsync());
145145

146-
Assert.False(value.NextColumn());
147-
Assert.False(value.NextRow());
146+
Assert.False(await value.NextColumnAsync());
147+
Assert.False(await value.NextRowAsync());
148148

149-
Assert.Null(value.GetValue());
149+
Assert.Null(await value.GetValueAsync());
150150
}
151151
}
152152
}

test/Spreadsheet/SheetBuilderTest.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ namespace BlackDigital.Report.Tests.Spreadsheet
77
public class SheetBuilderTest
88
{
99
[Fact]
10-
public void GenerateSheet()
10+
public async void GenerateSheet()
1111
{
1212
var spreadsheet = new WorkbookBuilder(new ReportConfiguration());
1313
var sheet = spreadsheet.AddSheet("Sheet1");
@@ -21,19 +21,19 @@ public void GenerateSheet()
2121

2222
sheet.AddValue(value, new SheetPosition(1, 1));
2323

24-
sheet.Generate();
24+
await sheet.GenerateAsync();
2525

26-
Assert.Contains("xl/worksheets/sheet1.xml", spreadsheet.Files.Keys);
27-
Assert.Contains("xl/worksheets/_rels/sheet1.xml.rels", spreadsheet.Files.Keys);
26+
Assert.Contains(spreadsheet.Files, f => f?.Filename == "/xl/worksheets/sheet1.xml");
27+
Assert.Contains(spreadsheet.Files, f => f?.Filename == "/xl/worksheets/_rels/sheet1.xml.rels");
2828

29-
using MemoryStream msSheet = new(spreadsheet.Files["xl/worksheets/sheet1.xml"]);
29+
using MemoryStream msSheet = new(spreadsheet.Files.First(f => f.Filename == "/xl/worksheets/sheet1.xml").Content);
3030
using StreamReader srSheet = new(msSheet);
3131
var sheetXml = srSheet.ReadToEnd();
3232

33-
var expected = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><x:worksheet xmlns:x=\"http://schemas.openxmlformats.org/spreadsheetml/2006/main\"><x:sheetData><x:row r=\"1\"><x:c r=\"A1\" t=\"str\">Hello</x:c><x:c r=\"B1\" t=\"str\">1</x:c></x:row><x:row r=\"2\"><x:c r=\"A2\" t=\"str\">World</x:c><x:c r=\"B2\" t=\"str\">2</x:c></x:row></x:sheetData></x:worksheet>";
33+
var expected = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><worksheet xmlns=\"http://schemas.openxmlformats.org/spreadsheetml/2006/main\"><sheetData><row r=\"1\"><c r=\"A1\" t=\"s\"><v>0</v></c><c r=\"B1\" t=\"n\"><v>1</v></c></row><row r=\"2\"><c r=\"A2\" t=\"s\"><v>1</v></c><c r=\"B2\" t=\"n\"><v>2</v></c></row></sheetData></worksheet>";
3434
Assert.Equal(expected, sheetXml);
3535

36-
using MemoryStream msSheetRels = new(spreadsheet.Files["xl/worksheets/_rels/sheet1.xml.rels"]);
36+
using MemoryStream msSheetRels = new(spreadsheet.Files.First(f => f.Filename == "/xl/worksheets/_rels/sheet1.xml.rels").Content);
3737
using StreamReader srSheetRels = new(msSheetRels);
3838

3939
var sheetRelsXml = srSheetRels.ReadToEnd();

test/Spreadsheet/TableBuilderTest.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ namespace BlackDigital.Report.Tests.Spreadsheet
77
public class TableBuilderTest
88
{
99
[Fact]
10-
public void GenerateTable()
10+
public async void GenerateTable()
1111
{
1212
var spreadsheet = new WorkbookBuilder(new ReportConfiguration());
1313
var sheet = spreadsheet.AddSheet("Sheet1");
@@ -28,18 +28,18 @@ public void GenerateTable()
2828
table.AddHeader(header);
2929
table.AddBody(body);
3030

31-
header.MoveToEnd();
32-
body.MoveToEnd();
31+
await header.MoveToEndAsync();
32+
await body.MoveToEndAsync();
3333

34-
table.Generate();
34+
await table.GenerateAsync();
3535

36-
Assert.Contains("xl/tables/table1.xml", spreadsheet.Files.Keys);
36+
Assert.Contains(spreadsheet.Files, f => f.Filename == "/xl/tables/table1.xml");
3737

38-
using MemoryStream msTable = new(spreadsheet.Files["xl/tables/table1.xml"]);
38+
using MemoryStream msTable = new(spreadsheet.Files.First(f => f.Filename == "/xl/tables/table1.xml").Content);
3939
using StreamReader srTable = new(msTable);
4040
var tableXml = srTable.ReadToEnd();
4141

42-
var expected = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><x:table xmlns:x=\"http://schemas.openxmlformats.org/spreadsheetml/2006/main\" id=\"1\" name=\"Table1\" displayName=\"Table1\" ref=\"A1:B3\" totalsRowShown=\"0\"><x:autoFilter ref=\"A1:B3\" /><x:tableColumns count=\"2\"><x:tableColumn id=\"1\" name=\"Header1\" /><x:tableColumn id=\"2\" name=\"Header2\" /></x:tableColumns><x:tableStyleInfo name=\"TableStyleMedium15\" showFirstColumn=\"0\" showLastColumn=\"0\" showRowStripes=\"1\" showColumnStripes=\"0\" /></x:table>";
42+
var expected = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><table xmlns=\"http://schemas.openxmlformats.org/spreadsheetml/2006/main\" id=\"1\" name=\"Table1\" displayName=\"Table1\" ref=\"A1:B3\" totalsRowShown=\"0\"><autoFilter ref=\"A1:B3\" /><tableColumns count=\"2\"><tableColumn id=\"1\" name=\"Header1\" /><tableColumn id=\"2\" name=\"Header2\" /></tableColumns><tableStyleInfo name=\"TableStyleMedium15\" showFirstColumn=\"0\" showLastColumn=\"0\" showRowStripes=\"1\" showColumnStripes=\"0\" /></table>";
4343
Assert.Equal(expected, tableXml);
4444
}
4545
}

0 commit comments

Comments
 (0)