Skip to content

Commit dfd643d

Browse files
committed
Changed tests to xUnit.
1 parent ab3a254 commit dfd643d

File tree

201 files changed

+3774
-3701
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

201 files changed

+3774
-3701
lines changed

CsvHelper.v3.ncrunchsolution

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<SolutionConfiguration>
22
<Settings>
33
<AllowParallelTestExecution>True</AllowParallelTestExecution>
4+
<InstrumentationMode>Optimised</InstrumentationMode>
45
<SolutionConfigured>True</SolutionConfigured>
56
</Settings>
67
</SolutionConfiguration>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<ProjectConfiguration>
2+
<Settings>
3+
<IgnoreThisComponentCompletely>True</IgnoreThisComponentCompletely>
4+
</Settings>
5+
</ProjectConfiguration>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<ProjectConfiguration>
2+
<Settings>
3+
<PreventSigningOfAssembly>True</PreventSigningOfAssembly>
4+
</Settings>
5+
</ProjectConfiguration>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<ProjectConfiguration>
2+
<Settings>
3+
<PreventSigningOfAssembly>True</PreventSigningOfAssembly>
4+
</Settings>
5+
</ProjectConfiguration>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<ProjectConfiguration>
2+
<Settings>
3+
<PreventSigningOfAssembly>True</PreventSigningOfAssembly>
4+
</Settings>
5+
</ProjectConfiguration>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<ProjectConfiguration>
2+
<Settings>
3+
<PreventSigningOfAssembly>True</PreventSigningOfAssembly>
4+
</Settings>
5+
</ProjectConfiguration>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<ProjectConfiguration>
2+
<Settings>
3+
<PreventSigningOfAssembly>True</PreventSigningOfAssembly>
4+
</Settings>
5+
</ProjectConfiguration>

src/CsvHelper/Properties/AssemblyInfo.cs

+6-2
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,9 @@
55
using System;
66
using System.Runtime.CompilerServices;
77

8-
[assembly: CLSCompliant( true )]
9-
[assembly: InternalsVisibleTo( "CsvHelper.Tests, PublicKey=00240000048000009400000006020000002400005253413100040000010001000db97564beef98ad18a76ba31f769fab92b14341c9c37ed12f8004bb2a1a7fe42ad829b0e285915a816f05a32325c5e0ba83bd69d8f4d26a0785ccf446749842ad038f7325601a99c59a323dfa7ecf210139159da0aad1822b5d9c9be6d914ecbaa8b8c908c4af798a89b8777010971d81975079a49662ced398c742ff186a94" )]
8+
[assembly: CLSCompliant(true)]
9+
#if NCRUNCH
10+
[assembly: InternalsVisibleTo("CsvHelper.Tests")]
11+
#else
12+
[assembly: InternalsVisibleTo("CsvHelper.Tests, PublicKey=00240000048000009400000006020000002400005253413100040000010001000db97564beef98ad18a76ba31f769fab92b14341c9c37ed12f8004bb2a1a7fe42ad829b0e285915a816f05a32325c5e0ba83bd69d8f4d26a0785ccf446749842ad038f7325601a99c59a323dfa7ecf210139159da0aad1822b5d9c9be6d914ecbaa8b8c908c4af798a89b8777010971d81975079a49662ced398c742ff186a94")]
13+
#endif

tests/CsvHelper.Tests/ArrayHelperTests.cs

+15-15
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// This file is a part of CsvHelper and is dual licensed under MS-PL and Apache 2.0.
33
// See LICENSE.txt for details or visit http://www.opensource.org/licenses/ms-pl.html for MS-PL and http://opensource.org/licenses/Apache-2.0 for Apache 2.0.
44
// https://github.com/JoshClose/CsvHelper
5-
using Microsoft.VisualStudio.TestTools.UnitTesting;
5+
using Xunit;
66
using System;
77
using System.Collections.Generic;
88
using System.Linq;
@@ -11,30 +11,30 @@
1111

1212
namespace CsvHelper.Tests
1313
{
14-
[TestClass]
14+
1515
public class ArrayHelperTests
1616
{
17-
[TestMethod]
17+
[Fact]
1818
public void Contains_HasValue_ReturnsTrue()
1919
{
2020
var array = new char[] { 'a' };
2121

2222
var contains = ArrayHelper.Contains(array, 'a');
2323

24-
Assert.IsTrue(contains);
24+
Assert.True(contains);
2525
}
2626

27-
[TestMethod]
27+
[Fact]
2828
public void Contains_DoesNotHaveValue_ReturnsFalse()
2929
{
3030
var array = new char[] { 'a' };
3131

3232
var contains = ArrayHelper.Contains(array, 'b');
3333

34-
Assert.IsFalse(contains);
34+
Assert.False(contains);
3535
}
3636

37-
[TestMethod]
37+
[Fact]
3838
public void Trim_FullBuffer_TrimsChars()
3939
{
4040
var buffer = " a ".ToCharArray();
@@ -44,11 +44,11 @@ public void Trim_FullBuffer_TrimsChars()
4444

4545
ArrayHelper.Trim(buffer, ref start, ref length, trimChars);
4646

47-
Assert.AreEqual(1, start);
48-
Assert.AreEqual(1, length);
47+
Assert.Equal(1, start);
48+
Assert.Equal(1, length);
4949
}
5050

51-
[TestMethod]
51+
[Fact]
5252
public void Trim_MidBuffer_TrimsChars()
5353
{
5454
var buffer = "a b c".ToCharArray();
@@ -58,11 +58,11 @@ public void Trim_MidBuffer_TrimsChars()
5858

5959
ArrayHelper.Trim(buffer, ref start, ref length, trimChars);
6060

61-
Assert.AreEqual(2, start);
62-
Assert.AreEqual(1, length);
61+
Assert.Equal(2, start);
62+
Assert.Equal(1, length);
6363
}
6464

65-
[TestMethod]
65+
[Fact]
6666
public void Trim_AllWhitespace_EmptyString()
6767
{
6868
var buffer = new string(' ', 100).ToCharArray();
@@ -72,8 +72,8 @@ public void Trim_AllWhitespace_EmptyString()
7272

7373
ArrayHelper.Trim(buffer, ref start, ref length, trimChars);
7474

75-
Assert.AreEqual(100, start);
76-
Assert.AreEqual(0, length);
75+
Assert.Equal(100, start);
76+
Assert.Equal(0, length);
7777
}
7878
}
7979
}

tests/CsvHelper.Tests/Async/ReadingTests.cs

+15-15
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,18 @@
33
// See LICENSE.txt for details or visit http://www.opensource.org/licenses/ms-pl.html for MS-PL and http://opensource.org/licenses/Apache-2.0 for Apache 2.0.
44
// https://github.com/JoshClose/CsvHelper
55
using CsvHelper.Tests.Mocks;
6-
using Microsoft.VisualStudio.TestTools.UnitTesting;
6+
using Xunit;
77
using System.Collections.Generic;
88
using System.Threading.Tasks;
99
using System.Threading;
1010
using System;
1111

1212
namespace CsvHelper.Tests.Async
1313
{
14-
[TestClass]
14+
1515
public class ReadingTests
1616
{
17-
[TestMethod]
17+
[Fact]
1818
public async Task ReadingTest()
1919
{
2020
var parser = new ParserMock
@@ -34,20 +34,20 @@ public async Task ReadingTest()
3434
records.Add(csv.GetRecord<Simple>());
3535
}
3636

37-
Assert.AreEqual(2, records.Count);
37+
Assert.Equal(2, records.Count);
3838

3939
var record = records[0];
40-
Assert.AreEqual(1, record.Id);
41-
Assert.AreEqual("one", record.Name);
40+
Assert.Equal(1, record.Id);
41+
Assert.Equal("one", record.Name);
4242

4343
record = records[1];
44-
Assert.AreEqual(2, record.Id);
45-
Assert.AreEqual("two", record.Name);
44+
Assert.Equal(2, record.Id);
45+
Assert.Equal("two", record.Name);
4646
}
4747
}
4848

4949
#if NETCOREAPP
50-
[TestMethod]
50+
[Fact]
5151
public async Task GetRecordsTest()
5252
{
5353
var parser = new ParserMock
@@ -62,17 +62,17 @@ public async Task GetRecordsTest()
6262
var records = csv.GetRecordsAsync<Simple>().GetAsyncEnumerator();
6363
await records.MoveNextAsync();
6464

65-
Assert.AreEqual(1, records.Current.Id);
66-
Assert.AreEqual("one", records.Current.Name);
65+
Assert.Equal(1, records.Current.Id);
66+
Assert.Equal("one", records.Current.Name);
6767

6868
await records.MoveNextAsync();
6969

70-
Assert.AreEqual(2, records.Current.Id);
71-
Assert.AreEqual("two", records.Current.Name);
70+
Assert.Equal(2, records.Current.Id);
71+
Assert.Equal("two", records.Current.Name);
7272
}
7373
}
7474

75-
[TestMethod]
75+
[Fact]
7676
public async Task GetRecordsTestCanceled()
7777
{
7878
var parser = new ParserMock
@@ -87,7 +87,7 @@ public async Task GetRecordsTestCanceled()
8787
{
8888
source.Cancel();
8989
var records = csv.GetRecordsAsync<Simple>(source.Token).GetAsyncEnumerator();
90-
await Assert.ThrowsExceptionAsync<OperationCanceledException>(async () => await records.MoveNextAsync());
90+
await Assert.ThrowsAsync<OperationCanceledException>(async () => await records.MoveNextAsync());
9191
}
9292
}
9393
#endif

tests/CsvHelper.Tests/Async/WritingTests.cs

+9-8
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// This file is a part of CsvHelper and is dual licensed under MS-PL and Apache 2.0.
33
// See LICENSE.txt for details or visit http://www.opensource.org/licenses/ms-pl.html for MS-PL and http://opensource.org/licenses/Apache-2.0 for Apache 2.0.
44
// https://github.com/JoshClose/CsvHelper
5-
using Microsoft.VisualStudio.TestTools.UnitTesting;
5+
using Xunit;
66
using System;
77
using System.Collections.Generic;
88
using System.Globalization;
@@ -13,10 +13,10 @@
1313

1414
namespace CsvHelper.Tests.Async
1515
{
16-
[TestClass]
16+
1717
public class WritingTests
1818
{
19-
[TestMethod]
19+
[Fact]
2020
public async Task WritingTest()
2121
{
2222
using (var stream = new MemoryStream())
@@ -45,11 +45,11 @@ public async Task WritingTest()
4545
expected.AppendLine("1,one");
4646
expected.AppendLine("2,two");
4747

48-
Assert.AreEqual(expected.ToString(), reader.ReadToEnd());
48+
Assert.Equal(expected.ToString(), reader.ReadToEnd());
4949
}
5050
}
5151

52-
[TestMethod]
52+
[Fact]
5353
public async Task WriteRecordsTest()
5454
{
5555
using (var stream = new MemoryStream())
@@ -72,11 +72,11 @@ public async Task WriteRecordsTest()
7272
expected.AppendLine("1,one");
7373
expected.AppendLine("2,two");
7474

75-
Assert.AreEqual(expected.ToString(), reader.ReadToEnd());
75+
Assert.Equal(expected.ToString(), reader.ReadToEnd());
7676
}
7777
}
7878

79-
[TestMethod]
79+
[Fact]
8080
public async Task WriteRecordsTestCanceled()
8181
{
8282
using (var source = new CancellationTokenSource())
@@ -92,6 +92,7 @@ public async Task WriteRecordsTestCanceled()
9292
new Simple { Id = 3, Name = "three" },
9393
};
9494
source.Cancel();
95+
9596
try
9697
{
9798
await csv.WriteRecordsAsync(records, source.Token);
@@ -104,7 +105,7 @@ public async Task WriteRecordsTestCanceled()
104105
}
105106
}
106107

107-
Assert.Fail("Did not throw exception");
108+
throw new XunitException("Did not throw exception");
108109
}
109110
}
110111

0 commit comments

Comments
 (0)