Skip to content

Commit 421622f

Browse files
committed
Use dotnet xunit for SideBySide tests.
1 parent cd5384d commit 421622f

File tree

11 files changed

+61
-56
lines changed

11 files changed

+61
-56
lines changed

.ci/test.ps1

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,25 +18,29 @@ if ($LASTEXITCODE -ne 0){
1818
}
1919
popd
2020

21+
pushd .\tests\SideBySide
22+
2123
echo "Executing tests with No Compression, No SSL"
22-
Copy-Item -Force .ci\config\config.json tests\SideBySide\config.json
23-
dotnet test tests\SideBySide\SideBySide.csproj -c Release
24+
Copy-Item -Force ..\..\.ci\config\config.json config.json
25+
dotnet xunit -c Release
2426
if ($LASTEXITCODE -ne 0){
2527
exit $LASTEXITCODE;
2628
}
2729
echo "Executing Debug Only tests"
28-
dotnet test tests\SideBySide\SideBySide.csproj -c Debug --filter "FullyQualifiedName~SideBySide.DebugOnlyTests"
30+
dotnet xunit -c Debug -class SideBySide.DebugOnlyTests
2931
if ($LASTEXITCODE -ne 0){
3032
exit $LASTEXITCODE;
3133
}
3234

3335
echo "Executing tests with Compression, No SSL"
34-
Copy-Item -Force .ci\config\config.compression.json tests\SideBySide\config.json
35-
dotnet test tests\SideBySide\SideBySide.csproj -c Release
36+
Copy-Item -Force ..\..\.ci\config\config.compression.json config.json
37+
dotnet xunit -c Release
3638
if ($LASTEXITCODE -ne 0){
3739
exit $LASTEXITCODE;
3840
}
3941

42+
popd
43+
4044
echo "Executing baseline connection string tests"
4145
dotnet restore tests\MySqlConnector.Tests\MySqlConnector.Tests.csproj /p:Configuration=Baseline
4246
dotnet test tests\MySqlConnector.Tests\MySqlConnector.Tests.csproj -c Baseline

.travis.yml

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,17 @@ before_install:
2626
script:
2727
- dotnet restore
2828
- pushd tests/MySqlConnector.Tests && dotnet xunit -c Release && popd
29-
- dotnet build tests/SideBySide/SideBySide.csproj -c Release -f netcoreapp2.0
30-
- echo 'Executing netcoreapp1.1.2 tests with No Compression, No SSL' && ./.ci/use-config.sh config.json 172.17.0.1 3307 $NAME $FEATURES && time dotnet test tests/SideBySide/SideBySide.csproj -c Release -f netcoreapp1.1.2
31-
- echo 'Executing netcoreapp2.0 tests with No Compression, No SSL' && ./.ci/use-config.sh config.json 172.17.0.1 3307 $NAME $FEATURES && time dotnet test tests/SideBySide/SideBySide.csproj -c Release -f netcoreapp2.0
32-
- echo 'Executing netcoreapp2.0 Debug Only tests' && time dotnet test tests/SideBySide/SideBySide.csproj -c Debug -f netcoreapp2.0 --filter "FullyQualifiedName~SideBySide.DebugOnlyTests"
33-
- echo 'Executing netcoreapp2.0 tests with Compression, No SSL' && ./.ci/use-config.sh config.compression.json 172.17.0.1 3307 $NAME $FEATURES && time dotnet test tests/SideBySide/SideBySide.csproj -c Release -f netcoreapp2.0
34-
- echo 'Executing netcoreapp2.0 tests with No Compression, SSL' && ./.ci/use-config.sh config.ssl.json 172.17.0.1 3307 $NAME $FEATURES && time dotnet test tests/SideBySide/SideBySide.csproj -c Release -f netcoreapp2.0
35-
- echo 'Executing netcoreapp2.0 tests with Compression, SSL' && ./.ci/use-config.sh config.compression+ssl.json 172.17.0.1 3307 $NAME $FEATURES && time dotnet test tests/SideBySide/SideBySide.csproj -c Release -f netcoreapp2.0
36-
- echo 'Executing netcoreapp2.0 tests with Unix Domain Socket, No Compression, No SSL' && ./.ci/use-config.sh config.uds.json 172.17.0.1 3307 $NAME $FEATURES && time dotnet test tests/SideBySide/SideBySide.csproj -c Release -f netcoreapp2.0
37-
- echo 'Executing netcoreapp2.0 tests with Buffering, No Compression, No SSL' && ./.ci/use-config.sh config.buffer.json 172.17.0.1 3307 $NAME $FEATURES && time dotnet test tests/SideBySide/SideBySide.csproj -c Release -f netcoreapp2.0
29+
- pushd tests/SideBySide
30+
- dotnet build SideBySide.csproj -c Release -f netcoreapp2.0
31+
- echo 'Executing netcoreapp1.1.2 tests with No Compression, No SSL' && ../../.ci/use-config.sh config.json 172.17.0.1 3307 $NAME $FEATURES && time dotnet xunit -c Release -f netcoreapp1.1.2
32+
- echo 'Executing netcoreapp2.0 tests with No Compression, No SSL' && ../../.ci/use-config.sh config.json 172.17.0.1 3307 $NAME $FEATURES && time dotnet xunit -c Release -f netcoreapp2.0
33+
- echo 'Executing netcoreapp2.0 Debug Only tests' && time dotnet xunit -c Debug -f netcoreapp2.0 -class SideBySide.DebugOnlyTests
34+
- echo 'Executing netcoreapp2.0 tests with Compression, No SSL' && ../../.ci/use-config.sh config.compression.json 172.17.0.1 3307 $NAME $FEATURES && time dotnet xunit -c Release -f netcoreapp2.0
35+
- echo 'Executing netcoreapp2.0 tests with No Compression, SSL' && ../../.ci/use-config.sh config.ssl.json 172.17.0.1 3307 $NAME $FEATURES && time dotnet xunit -c Release -f netcoreapp2.0
36+
- echo 'Executing netcoreapp2.0 tests with Compression, SSL' && ../../.ci/use-config.sh config.compression+ssl.json 172.17.0.1 3307 $NAME $FEATURES && time dotnet xunit -c Release -f netcoreapp2.0
37+
- echo 'Executing netcoreapp2.0 tests with Unix Domain Socket, No Compression, No SSL' && ../../.ci/use-config.sh config.uds.json 172.17.0.1 3307 $NAME $FEATURES && time dotnet xunit -c Release -f netcoreapp2.0
38+
- echo 'Executing netcoreapp2.0 tests with Buffering, No Compression, No SSL' && ../../.ci/use-config.sh config.buffer.json 172.17.0.1 3307 $NAME $FEATURES && time dotnet xunit -c Release -f netcoreapp2.0
39+
- popd
3840

3941
after_script:
4042
- chmod +x .ci/build-docs.sh && ./.ci/build-docs.sh

tests/SideBySide/BulkLoaderAsync.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -191,19 +191,19 @@ public async Task BulkLoadLocalCsvFileNotFound()
191191
}
192192
else
193193
{
194-
Assert.IsType(typeof(System.IO.FileNotFoundException), mySqlException.InnerException);
194+
Assert.IsType<System.IO.FileNotFoundException>(mySqlException.InnerException);
195195
break;
196196
}
197197
}
198198
if (mySqlException.InnerException == null)
199199
{
200-
Assert.IsType(typeof(System.IO.FileNotFoundException), mySqlException);
200+
Assert.IsType<System.IO.FileNotFoundException>(mySqlException);
201201
}
202202
}
203203
catch (Exception exception)
204204
{
205205
//We know that the exception is not a MySqlException, just use the assertion to fail the test
206-
Assert.IsType(typeof(MySqlException), exception);
206+
Assert.IsType<MySqlException>(exception);
207207
};
208208
}
209209

tests/SideBySide/BulkLoaderSync.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -193,19 +193,19 @@ public void BulkLoadLocalCsvFileNotFound()
193193
}
194194
else
195195
{
196-
Assert.IsType(typeof(System.IO.FileNotFoundException), mySqlException.InnerException);
196+
Assert.IsType<System.IO.FileNotFoundException>(mySqlException.InnerException);
197197
break;
198198
}
199199
}
200200
if (mySqlException.InnerException == null)
201201
{
202-
Assert.IsType(typeof(System.IO.FileNotFoundException), mySqlException);
202+
Assert.IsType<System.IO.FileNotFoundException>(mySqlException);
203203
}
204204
}
205205
catch (Exception exception)
206206
{
207207
//We know that the exception is not a MySqlException, just use the assertion to fail the test
208-
Assert.IsType(typeof(MySqlException), exception);
208+
Assert.IsType<MySqlException>(exception);
209209
};
210210
}
211211

tests/SideBySide/CancelTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System;
1+
using System;
22
using System.Data;
33
using System.Diagnostics;
44
using System.Linq;
@@ -166,7 +166,7 @@ public void DapperQueryMultiple()
166166
using (var gridReader = m_database.Connection.QueryMultiple(@"select 1; " + c_hugeQuery))
167167
{
168168
var first = gridReader.Read<int>().ToList();
169-
Assert.Equal(1, first.Count);
169+
Assert.Single(first);
170170
Assert.Equal(1, first[0]);
171171

172172
// don't read the second result set; disposing the GridReader should Cancel the command

tests/SideBySide/DataTypes.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System;
1+
using System;
22
using System.Data.Common;
33
using System.Globalization;
44
using System.Linq;
@@ -91,7 +91,7 @@ public async Task GetInt64(string column, int[] flags, long[] values)
9191
await DoGetValue(column, (r, n) => r.GetInt64(n), flags, values).ConfigureAwait(false);
9292
}
9393

94-
public async Task DoGetValue<T>(string column, Func<DbDataReader, int, T> getInt, int[] flags, T[] values)
94+
private async Task DoGetValue<T>(string column, Func<DbDataReader, int, T> getInt, int[] flags, T[] values)
9595
{
9696
using (var cmd = m_database.Connection.CreateCommand())
9797
{
@@ -612,8 +612,8 @@ private static byte[] CreateByteArray(int size)
612612
}
613613

614614
[RequiresFeatureTheory(ServerFeatures.Json)]
615-
[InlineData("Value", new[] { null, "NULL", "BOOLEAN", "ARRAY", "ARRAY", "ARRAY", "INTEGER", "INTEGER", "OBJECT", "OBJECT" })]
616-
public void JsonType(string column, string[] expectedTypes)
615+
[InlineData(new object[] { new[] { null, "NULL", "BOOLEAN", "ARRAY", "ARRAY", "ARRAY", "INTEGER", "INTEGER", "OBJECT", "OBJECT" }})]
616+
public void JsonType(string[] expectedTypes)
617617
{
618618
var types = m_database.Connection.Query<string>(@"select JSON_TYPE(value) from datatypes_json_core order by rowid;").ToList();
619619
Assert.Equal(expectedTypes, types);

tests/SideBySide/InsertTests.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System;
1+
using System;
22
using System.Linq;
33
using MySql.Data.MySqlClient;
44
using Dapper;
@@ -27,7 +27,7 @@ public async Task LastInsertedId()
2727
{
2828
command.Parameters.Add(new MySqlParameter { ParameterName = "@text", Value = "test" });
2929
await command.ExecuteNonQueryAsync();
30-
Assert.Equal(command.LastInsertedId, 1L);
30+
Assert.Equal(1L, command.LastInsertedId);
3131
}
3232
}
3333
finally
@@ -70,7 +70,7 @@ public void LastInsertedIdExplicitStart()
7070
using (var command = new MySqlCommand("insert into insert_ai_2(text) values('test');", m_database.Connection))
7171
{
7272
command.ExecuteNonQuery();
73-
Assert.Equal(command.LastInsertedId, 1234L);
73+
Assert.Equal(1234L, command.LastInsertedId);
7474
}
7575
}
7676
finally
@@ -207,9 +207,9 @@ public void InsertEnumValue()
207207
new { e16a = default(Enum16?), e32a = default(Enum32?), e64a = default(Enum64?), e16b = Enum16.On, e32b = Enum32.Off, e64b = Enum64.On });
208208
var results = m_database.Connection.Query<EnumValues>(@"select Enum16, Enum32, Enum64 from insert_enum_value order by rowid;").ToList();
209209
Assert.Equal(2, results.Count);
210-
Assert.Equal(null, results[0].Enum16);
211-
Assert.Equal(null, results[0].Enum32);
212-
Assert.Equal(null, results[0].Enum64);
210+
Assert.Null(results[0].Enum16);
211+
Assert.Null(results[0].Enum32);
212+
Assert.Null(results[0].Enum64);
213213
Assert.Equal(Enum16.On, results[1].Enum16);
214214
Assert.Equal(Enum32.Off, results[1].Enum32);
215215
Assert.Equal(Enum64.On, results[1].Enum64);

tests/SideBySide/QueryTests.cs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public void NextResultBeforeRead()
6767
{
6868
cmd.CommandText = "select id, value FROM query_test;";
6969
using (var reader = cmd.ExecuteReader())
70-
Assert.Equal(false, reader.NextResult());
70+
Assert.False(reader.NextResult());
7171
}
7272
}
7373

@@ -201,23 +201,23 @@ public async Task MultipleBufferedReaders()
201201

202202
var readers = new[]{ await cmd1.ExecuteReaderAsync(), await cmd2.ExecuteReaderAsync() };
203203
foreach (var reader in readers){
204-
Assert.Equal(true, await reader.ReadAsync());
204+
Assert.True(await reader.ReadAsync());
205205
Assert.Equal(1, reader.GetInt32(0));
206-
Assert.Equal(true, await reader.ReadAsync());
206+
Assert.True(await reader.ReadAsync());
207207
Assert.Equal(2, reader.GetInt32(0));
208-
Assert.Equal(true, await reader.ReadAsync());
208+
Assert.True(await reader.ReadAsync());
209209
Assert.Equal(3, reader.GetInt32(0));
210-
Assert.Equal(false, await reader.ReadAsync());
211-
Assert.Equal(true, await reader.NextResultAsync());
210+
Assert.False(await reader.ReadAsync());
211+
Assert.True(await reader.NextResultAsync());
212212

213-
Assert.Equal(true, await reader.ReadAsync());
213+
Assert.True(await reader.ReadAsync());
214214
Assert.Equal(3, reader.GetInt32(0));
215-
Assert.Equal(true, await reader.ReadAsync());
215+
Assert.True(await reader.ReadAsync());
216216
Assert.Equal(2, reader.GetInt32(0));
217-
Assert.Equal(true, await reader.ReadAsync());
217+
Assert.True(await reader.ReadAsync());
218218
Assert.Equal(1, reader.GetInt32(0));
219-
Assert.Equal(false, await reader.ReadAsync());
220-
Assert.Equal(false, await reader.NextResultAsync());
219+
Assert.False(await reader.ReadAsync());
220+
Assert.False(await reader.NextResultAsync());
221221
}
222222
}
223223
}
@@ -242,14 +242,14 @@ public async Task UndisposedReader()
242242
cmd2.CommandText = commandText;
243243

244244
var reader1 = await cmd1.ExecuteReaderAsync();
245-
Assert.Equal(true, reader1.Read());
245+
Assert.True(reader1.Read());
246246
Assert.Equal(1, reader1.GetInt32(0));
247247

248248
m_database.Connection.Close();
249249
m_database.Connection.Open();
250250

251251
var reader2 = await cmd1.ExecuteReaderAsync();
252-
Assert.Equal(true, reader2.Read());
252+
Assert.True(reader2.Read());
253253
Assert.Equal(1, reader2.GetInt32(0));
254254
}
255255
}
@@ -379,7 +379,7 @@ public async Task DoubleDispose()
379379
cmd.CommandText = @"select 1;";
380380
using (var reader = await cmd.ExecuteReaderAsync().ConfigureAwait(false))
381381
{
382-
Assert.Equal(true, await reader.ReadAsync().ConfigureAwait(false));
382+
Assert.True(await reader.ReadAsync().ConfigureAwait(false));
383383
reader.Dispose();
384384
reader.Dispose();
385385
}

tests/SideBySide/SideBySide.csproj

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,9 @@
2222

2323
<ItemGroup>
2424
<!--testing packages-->
25-
<PackageReference Include="Microsoft.DotNet.InternalAbstractions" Version="1.0.0" />
26-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.0.0-*" />
27-
<PackageReference Include="Microsoft.TestPlatform.TestHost" Version="15.0.0-*" />
28-
<PackageReference Include="xunit" Version="2.2.0" />
29-
<PackageReference Include="xunit.runner.visualstudio" Version="2.2.0" />
25+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.3.0" />
26+
<PackageReference Include="xunit" Version="2.3.0-beta5-build3769" />
27+
<DotNetCliToolReference Include="dotnet-xunit" Version="2.3.0-beta5-build3769" />
3028
<!--app packages-->
3129
<PackageReference Include="Dapper" Version="1.50.2" />
3230
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="1.1.1" />
@@ -38,6 +36,7 @@
3836
</ItemGroup>
3937

4038
<ItemGroup Condition=" '$(Configuration)' == 'Baseline' ">
39+
<PackageReference Include="xunit.runner.visualstudio" Version="2.2.0" />
4140
<PackageReference Include="MySql.Data" Version="6.9.9" />
4241
</ItemGroup>
4342

tests/SideBySide/SslTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System.IO;
1+
using System.IO;
22
using System.Threading.Tasks;
33
using MySql.Data.MySqlClient;
44
using Xunit;
@@ -106,7 +106,7 @@ public async Task ConnectSslBadCaCertificate()
106106
#endif
107107
using (var connection = new MySqlConnection(csb.ConnectionString))
108108
{
109-
await Assert.ThrowsAsync(typeof(MySqlException), async () => await connection.OpenAsync());
109+
await Assert.ThrowsAsync<MySqlException>(async () => await connection.OpenAsync());
110110
}
111111
}
112112

0 commit comments

Comments
 (0)