Skip to content

Commit fc56902

Browse files
Convert tests to xunit and update nuget packages (#135)
* Convert tests to xunit and update nuget packages * Fix typo in readme
1 parent e81ace4 commit fc56902

Some content is hidden

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

45 files changed

+808
-782
lines changed

MbDotNet.Tests/Acceptance/AcceptanceTestBase.cs

-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.Text;
4-
51
namespace MbDotNet.Tests.Acceptance
62
{
73
public class AcceptanceTestBase
+15-10
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,30 @@
11
using System.Threading.Tasks;
2-
using Microsoft.VisualStudio.TestTools.UnitTesting;
2+
3+
using Xunit;
34

45
namespace MbDotNet.Tests.Acceptance
56
{
6-
[TestClass, TestCategory("Acceptance")]
7+
[Trait("Category", "Acceptance")]
8+
[Collection("Sequential")]
79
public class ConfigTests : AcceptanceTestBase
810
{
9-
[TestInitialize]
10-
public async Task TestInitialize()
11+
/// <summary>
12+
/// It act as test initialize in x unit
13+
/// at https://xunit.net/docs/comparisons
14+
/// </summary>
15+
public ConfigTests()
1116
{
12-
await _client.DeleteAllImpostersAsync();
17+
_client.DeleteAllImpostersAsync().ConfigureAwait(false);
1318
}
1419

15-
[TestMethod]
20+
[Fact]
1621
public async Task GetConfig()
1722
{
1823
var result = await _client.GetConfigAsync();
19-
Assert.IsNotNull(result);
20-
Assert.IsNotNull(result.Version);
21-
Assert.IsTrue(result.Process.Count > 0);
22-
Assert.IsTrue(result.Options.Count > 0);
24+
Assert.NotNull(result);
25+
Assert.NotNull(result.Version);
26+
Assert.True(result.Process.Count > 0);
27+
Assert.True(result.Options.Count > 0);
2328
}
2429
}
2530
}

MbDotNet.Tests/Acceptance/DocumentationTests.cs

+29-23
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
using MbDotNet.Models.Predicates.Fields;
88
using MbDotNet.Models.Responses;
99
using MbDotNet.Models.Responses.Fields;
10-
using Microsoft.VisualStudio.TestTools.UnitTesting;
10+
11+
using Xunit;
1112

1213
namespace MbDotNet.Tests.Acceptance
1314
{
@@ -17,20 +18,24 @@ namespace MbDotNet.Tests.Acceptance
1718
/// See the comment above each individual test to figure out which
1819
/// example it is describing.
1920
/// </summary>
20-
[TestClass, TestCategory("Acceptance")]
21+
[Trait("Category", "Acceptance")]
22+
[Collection("Sequential")]
2123
public class DocumentationTests : AcceptanceTestBase
2224
{
23-
[TestInitialize]
24-
public async Task TestInitialize()
25+
/// <summary>
26+
/// It act as test initialize in x unit
27+
/// at https://xunit.net/docs/comparisons
28+
/// </summary>
29+
public DocumentationTests()
2530
{
26-
await _client.DeleteAllImpostersAsync();
31+
_client.DeleteAllImpostersAsync().ConfigureAwait(false);
2732
}
2833

2934
/// <summary>
3035
/// This test shows how to setup the imposter in the stub example
3136
/// at http://www.mbtest.org/docs/api/stubs.
3237
/// </summary>
33-
[TestMethod]
38+
[Fact]
3439
public async Task StubExample()
3540
{
3641
await _client.CreateHttpImposterAsync(4545, "StubExample", imposter =>
@@ -45,7 +50,7 @@ await _client.CreateHttpImposterAsync(4545, "StubExample", imposter =>
4550
/// This test shows how to setup the imposter with a dynamic port chosen by Mountebank
4651
/// See imposter resource at http://www.mbtest.org/docs/api/contracts for more information.
4752
/// </summary>
48-
[TestMethod]
53+
[Fact]
4954
public async Task DynamicPortExample()
5055
{
5156
await _client.CreateHttpImposterAsync(null, "DynamicPort", _ => { });
@@ -55,7 +60,7 @@ public async Task DynamicPortExample()
5560
/// This test shows how to setup the imposter in the equals predicate example
5661
/// at http://www.mbtest.org/docs/api/predicates.
5762
/// </summary>
58-
[TestMethod]
63+
[Fact]
5964
public async Task EqualsPredicateExample()
6065
{
6166
await _client.CreateHttpImposterAsync(4545, "EqualsPredicateExample", imposter =>
@@ -77,7 +82,8 @@ await _client.CreateHttpImposterAsync(4545, "EqualsPredicateExample", imposter =
7782

7883
var complexPredicate = new EqualsPredicate<HttpPredicateFields>(complexPredicateFields);
7984

80-
imposter.AddStub().On(complexPredicate).On(bodyPredicate).ReturnsStatus(HttpStatusCode.BadRequest);
85+
imposter.AddStub()
86+
.On(complexPredicate).On(bodyPredicate).ReturnsStatus(HttpStatusCode.BadRequest);
8187

8288
// Second stub
8389
var fields = new HttpPredicateFields
@@ -99,7 +105,7 @@ await _client.CreateHttpImposterAsync(4545, "EqualsPredicateExample", imposter =
99105
/// This test shows how to setup the imposter in the deepEquals predicate example
100106
/// at http://www.mbtest.org/docs/api/predicates.
101107
/// </summary>
102-
[TestMethod]
108+
[Fact]
103109
public async Task DeepEqualsPredicateExample()
104110
{
105111
await _client.CreateHttpImposterAsync(4556, "DeepEqualsPredicateExample", imposter =>
@@ -152,7 +158,7 @@ await _client.CreateHttpImposterAsync(4556, "DeepEqualsPredicateExample", impost
152158
/// This test shows how to setup the imposter in the contains predicate example
153159
/// at http://www.mbtest.org/docs/api/predicates.
154160
/// </summary>
155-
[TestMethod]
161+
[Fact]
156162
public async Task ContainsPredicateExample()
157163
{
158164
await _client.CreateTcpImposterAsync(4547, "ContainsPredicateExample", imposter =>
@@ -192,7 +198,7 @@ await _client.CreateTcpImposterAsync(4547, "ContainsPredicateExample", imposter
192198
/// This test shows how to setup the imposter in the startsWith predicate example
193199
/// at http://www.mbtest.org/docs/api/predicates.
194200
/// </summary>
195-
[TestMethod]
201+
[Fact]
196202
public async Task StartsWithPredicateExample()
197203
{
198204
await _client.CreateTcpImposterAsync(4548, "StartsWithPredicateExample", imposter =>
@@ -230,7 +236,7 @@ await _client.CreateTcpImposterAsync(4548, "StartsWithPredicateExample", imposte
230236
/// This test shows how to setup the imposter in the endsWith predicate example
231237
/// at http://www.mbtest.org/docs/api/predicates.
232238
/// </summary>
233-
[TestMethod]
239+
[Fact]
234240
public async Task EndsWithPredicateExample()
235241
{
236242
await _client.CreateTcpImposterAsync(4549, "EndsWithPredicateExample", imposter =>
@@ -270,7 +276,7 @@ await _client.CreateTcpImposterAsync(4549, "EndsWithPredicateExample", imposter
270276
/// This test shows how to setup the imposter in the matches predicate example
271277
/// at http://www.mbtest.org/docs/api/predicates.
272278
/// </summary>
273-
[TestMethod]
279+
[Fact]
274280
public async Task MatchesPredicateExample()
275281
{
276282
await _client.CreateTcpImposterAsync(4550, "MatchesPredicateExample", imposter =>
@@ -308,7 +314,7 @@ await _client.CreateTcpImposterAsync(4550, "MatchesPredicateExample", imposter =
308314
/// This test shows how to setup the imposter in the exists predicate example
309315
/// at http://www.mbtest.org/docs/api/predicates.
310316
/// </summary>
311-
[TestMethod]
317+
[Fact]
312318
public async Task ExistsPredicateExample()
313319
{
314320
await _client.CreateHttpImposterAsync(4550, "ExistsPredicateExample", imposter =>
@@ -343,7 +349,7 @@ await _client.CreateHttpImposterAsync(4550, "ExistsPredicateExample", imposter =
343349
/// This test shows how to setup the imposter in the not predicate example
344350
/// at http://www.mbtest.org/docs/api/predicates.
345351
/// </summary>
346-
[TestMethod]
352+
[Fact]
347353
public async Task NotPredicateExample()
348354
{
349355
await _client.CreateTcpImposterAsync(4552, "NotPredicateExample", imposter =>
@@ -364,7 +370,7 @@ await _client.CreateTcpImposterAsync(4552, "NotPredicateExample", imposter =>
364370
/// This test shows how to setup the imposter in the or predicate example
365371
/// at http://www.mbtest.org/docs/api/predicates.
366372
/// </summary>
367-
[TestMethod]
373+
[Fact]
368374
public async Task OrPredicateExample()
369375
{
370376
await _client.CreateTcpImposterAsync(4553, "OrPredicateExample", imposter =>
@@ -389,7 +395,7 @@ await _client.CreateTcpImposterAsync(4553, "OrPredicateExample", imposter =>
389395
/// This test shows how to setup the imposter in the and predicate example
390396
/// at http://www.mbtest.org/docs/api/predicates.
391397
/// </summary>
392-
[TestMethod]
398+
[Fact]
393399
public async Task AndPredicateExample()
394400
{
395401
await _client.CreateTcpImposterAsync(4554, "AndPredicateExample", imposter =>
@@ -414,7 +420,7 @@ await _client.CreateTcpImposterAsync(4554, "AndPredicateExample", imposter =>
414420
/// This test shows how to setup the imposter in the json example
415421
/// at http://localhost:2525/docs/api/json.
416422
/// </summary>
417-
[TestMethod]
423+
[Fact]
418424
public async Task JsonExample()
419425
{
420426
await _client.CreateHttpImposterAsync(4545, "JsonExample", imposter =>
@@ -442,7 +448,7 @@ await _client.CreateHttpImposterAsync(4545, "JsonExample", imposter =>
442448
/// This test shows how to setup the imposter in the stub with wait behavior
443449
/// at https://www.mbtest.org/docs/api/behaviors#behavior-wait
444450
/// </summary>
445-
[TestMethod]
451+
[Fact]
446452
public async Task WaitBehaviorExample()
447453
{
448454
await _client.CreateHttpImposterAsync(4546, "WaitBehaviorExample", imposter =>
@@ -456,7 +462,7 @@ await _client.CreateHttpImposterAsync(4546, "WaitBehaviorExample", imposter =>
456462
/// This test shows how to setup the imposter in the inject predicate example
457463
/// at http://www.mbtest.org/docs/api/injection.
458464
/// </summary>
459-
[TestMethod]
465+
[Fact]
460466
public async Task HttpInjectPredicateExample()
461467
{
462468
await _client.CreateHttpImposterAsync(4547, "HttpInjectPredicateExample", imposter =>
@@ -471,7 +477,7 @@ await _client.CreateHttpImposterAsync(4547, "HttpInjectPredicateExample", impost
471477
/// This test shows how to setup the imposter in the connection reset fault response example
472478
/// at http://www.mbtest.org/docs/api/faults#connection-reset.
473479
/// </summary>
474-
[TestMethod]
480+
[Fact]
475481
public async Task ConnectionResetFaultResponseExample()
476482
{
477483
await _client.CreateTcpImposterAsync(4554, imposter =>
@@ -485,7 +491,7 @@ await _client.CreateTcpImposterAsync(4554, imposter =>
485491
/// This test shows how to setup the imposter in the random data fault response example
486492
/// at http://www.mbtest.org/docs/api/faults#random-data-then-close.
487493
/// </summary>
488-
[TestMethod]
494+
[Fact]
489495
public async Task RandomDataFaultResponseExample()
490496
{
491497
await _client.CreateTcpImposterAsync(4554, imposter =>

0 commit comments

Comments
 (0)