Skip to content

Commit 7880216

Browse files
committed
chore: migrates of FA to xunit first batch
Signed-off-by: Vincent Biret <[email protected]>
1 parent d087d24 commit 7880216

21 files changed

+97
-114
lines changed

test/Microsoft.OpenApi.Readers.Tests/OpenApiReaderTests/OpenApiDiagnosticTests.cs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
// Copyright (c) Microsoft Corporation. All rights reserved.
22
// Licensed under the MIT license.
33

4-
using System.Collections.Generic;
54
using System.Threading.Tasks;
65
using System;
7-
using FluentAssertions;
8-
using Microsoft.OpenApi.Exceptions;
96
using Microsoft.OpenApi.Models;
107
using Xunit;
118
using System.IO;
@@ -27,17 +24,17 @@ public async Task DetectedSpecificationVersionShouldBeV2_0()
2724
{
2825
var actual = await OpenApiDocument.LoadAsync("V2Tests/Samples/basic.v2.yaml");
2926

30-
actual.Diagnostic.Should().NotBeNull();
31-
actual.Diagnostic.SpecificationVersion.Should().Be(OpenApiSpecVersion.OpenApi2_0);
27+
Assert.NotNull(actual.Diagnostic);
28+
Assert.Equal(OpenApiSpecVersion.OpenApi2_0, actual.Diagnostic.SpecificationVersion);
3229
}
3330

3431
[Fact]
3532
public async Task DetectedSpecificationVersionShouldBeV3_0()
3633
{
3734
var actual = await OpenApiDocument.LoadAsync("V3Tests/Samples/OpenApiDocument/minimalDocument.yaml");
3835

39-
actual.Diagnostic.Should().NotBeNull();
40-
actual.Diagnostic.SpecificationVersion.Should().Be(OpenApiSpecVersion.OpenApi3_0);
36+
Assert.NotNull(actual.Diagnostic);
37+
Assert.Equal(OpenApiSpecVersion.OpenApi3_0, actual.Diagnostic.SpecificationVersion);
4138
}
4239

4340
[Fact]
@@ -56,7 +53,7 @@ public async Task DiagnosticReportMergedForExternalReferenceAsync()
5653

5754
Assert.NotNull(result);
5855
Assert.NotNull(result.Document.Workspace);
59-
result.Diagnostic.Errors.Should().BeEmpty();
56+
Assert.Empty(result.Diagnostic.Errors);
6057
}
6158
}
6259

test/Microsoft.OpenApi.Readers.Tests/OpenApiReaderTests/UnsupportedSpecVersionTests.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
// Licensed under the MIT license.
33

44
using System.Threading.Tasks;
5-
using FluentAssertions;
65
using Microsoft.OpenApi.Exceptions;
76
using Microsoft.OpenApi.Models;
87
using Xunit;
@@ -21,7 +20,7 @@ public async Task ThrowOpenApiUnsupportedSpecVersionException()
2120
}
2221
catch (OpenApiUnsupportedSpecVersionException exception)
2322
{
24-
exception.SpecificationVersion.Should().Be("1.0.0");
23+
Assert.Equal("1.0.0", exception.SpecificationVersion);
2524
}
2625
}
2726
}

test/Microsoft.OpenApi.Readers.Tests/ParseNodeTests.cs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
// Licensed under the MIT license.
33

44
using System.Collections.Generic;
5-
using FluentAssertions;
65
using Microsoft.OpenApi.Exceptions;
76
using Microsoft.OpenApi.Models;
87
using Microsoft.OpenApi.Reader;
@@ -33,9 +32,9 @@ public void BrokenSimpleList()
3332

3433
var result = OpenApiDocument.Parse(input, "yaml");
3534

36-
result.Diagnostic.Errors.Should().BeEquivalentTo(new List<OpenApiError>() {
35+
Assert.Equivalent(new List<OpenApiError>() {
3736
new OpenApiError(new OpenApiReaderException("Expected a value."))
38-
});
37+
}, result.Diagnostic.Errors);
3938
}
4039

4140
[Fact]
@@ -59,12 +58,12 @@ public void BadSchema()
5958

6059
var res= OpenApiDocument.Parse(input, "yaml");
6160

62-
res.Diagnostic.Errors.Should().BeEquivalentTo(new List<OpenApiError>
61+
Assert.Equivalent(new List<OpenApiError>
6362
{
6463
new(new OpenApiReaderException("schema must be a map/object") {
6564
Pointer = "#/paths/~1foo/get/responses/200/content/application~1json/schema"
6665
})
67-
});
66+
}, res.Diagnostic.Errors);
6867
}
6968
}
7069
}

test/Microsoft.OpenApi.Readers.Tests/ReferenceService/ConvertToOpenApiReferenceV2Tests.cs

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// Copyright (c) Microsoft Corporation. All rights reserved.
22
// Licensed under the MIT license.
33

4-
using FluentAssertions;
54
using Microsoft.OpenApi.Models;
65
using Microsoft.OpenApi.Reader;
76
using Microsoft.OpenApi.Reader.V2;
@@ -31,9 +30,9 @@ public void ParseExternalReferenceToV2OpenApi()
3130
var reference = versionService.ConvertToOpenApiReference(input, null);
3231

3332
// Assert
34-
reference.ExternalResource.Should().Be(externalResource);
35-
reference.Type.Should().NotBeNull();
36-
reference.Id.Should().Be(id);
33+
Assert.Equal(externalResource, reference.ExternalResource);
34+
Assert.NotNull(reference.Type);
35+
Assert.Equal(id, reference.Id);
3736
}
3837

3938
[Fact]
@@ -49,9 +48,9 @@ public void ParseExternalReference()
4948
var reference = versionService.ConvertToOpenApiReference(input, null);
5049

5150
// Assert
52-
reference.ExternalResource.Should().Be(externalResource);
53-
reference.Type.Should().BeNull();
54-
reference.Id.Should().Be(id);
51+
Assert.Equal(externalResource, reference.ExternalResource);
52+
Assert.Null(reference.Type);
53+
Assert.Equal(id, reference.Id);
5554
}
5655

5756
[Fact]
@@ -67,9 +66,9 @@ public void ParseLocalParameterReference()
6766
var reference = versionService.ConvertToOpenApiReference(input, referenceType);
6867

6968
// Assert
70-
reference.Type.Should().Be(referenceType);
71-
reference.ExternalResource.Should().BeNull();
72-
reference.Id.Should().Be(id);
69+
Assert.Equal(referenceType, reference.Type);
70+
Assert.Null(reference.ExternalResource);
71+
Assert.Equal(id, reference.Id);
7372
}
7473

7574
[Fact]
@@ -85,9 +84,9 @@ public void ParseLocalSchemaReference()
8584
var reference = versionService.ConvertToOpenApiReference(input, referenceType);
8685

8786
// Assert
88-
reference.Type.Should().Be(referenceType);
89-
reference.ExternalResource.Should().BeNull();
90-
reference.Id.Should().Be(id);
87+
Assert.Equal(referenceType, reference.Type);
88+
Assert.Null(reference.ExternalResource);
89+
Assert.Equal(id, reference.Id);
9190
}
9291

9392
[Fact]
@@ -103,9 +102,9 @@ public void ParseTagReference()
103102
var reference = versionService.ConvertToOpenApiReference(input, referenceType);
104103

105104
// Assert
106-
reference.Type.Should().Be(referenceType);
107-
reference.ExternalResource.Should().BeNull();
108-
reference.Id.Should().Be(id);
105+
Assert.Equal(referenceType, reference.Type);
106+
Assert.Null(reference.ExternalResource);
107+
Assert.Equal(id, reference.Id);
109108
}
110109

111110
[Fact]
@@ -121,9 +120,9 @@ public void ParseSecuritySchemeReference()
121120
var reference = versionService.ConvertToOpenApiReference(input, referenceType);
122121

123122
// Assert
124-
reference.Type.Should().Be(referenceType);
125-
reference.ExternalResource.Should().BeNull();
126-
reference.Id.Should().Be(id);
123+
Assert.Equal(referenceType, reference.Type);
124+
Assert.Null(reference.ExternalResource);
125+
Assert.Equal(id, reference.Id);
127126
}
128127
}
129128
}

test/Microsoft.OpenApi.Readers.Tests/ReferenceService/ConvertToOpenApiReferenceV3Tests.cs

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// Copyright (c) Microsoft Corporation. All rights reserved.
22
// Licensed under the MIT license.
33

4-
using FluentAssertions;
54
using Microsoft.OpenApi.Models;
65
using Microsoft.OpenApi.Reader;
76
using Microsoft.OpenApi.Reader.V3;
@@ -31,9 +30,9 @@ public void ParseExternalReference()
3130
var reference = versionService.ConvertToOpenApiReference(input, null);
3231

3332
// Assert
34-
reference.Type.Should().BeNull();
35-
reference.ExternalResource.Should().Be(externalResource);
36-
reference.Id.Should().Be(id);
33+
Assert.Null(reference.Type);
34+
Assert.Equal(externalResource, reference.ExternalResource);
35+
Assert.Equal(id, reference.Id);
3736
}
3837

3938
[Fact]
@@ -49,9 +48,9 @@ public void ParseLocalParameterReference()
4948
var reference = versionService.ConvertToOpenApiReference(input, referenceType);
5049

5150
// Assert
52-
reference.Type.Should().Be(referenceType);
53-
reference.ExternalResource.Should().BeNull();
54-
reference.Id.Should().Be(id);
51+
Assert.Equal(referenceType, reference.Type);
52+
Assert.Null(reference.ExternalResource);
53+
Assert.Equal(id, reference.Id);
5554
}
5655

5756
[Fact]
@@ -67,9 +66,9 @@ public void ParseLocalSchemaReference()
6766
var reference = versionService.ConvertToOpenApiReference(input, referenceType);
6867

6968
// Assert
70-
reference.Type.Should().Be(referenceType);
71-
reference.ExternalResource.Should().BeNull();
72-
reference.Id.Should().Be(id);
69+
Assert.Equal(referenceType, reference.Type);
70+
Assert.Null(reference.ExternalResource);
71+
Assert.Equal(id, reference.Id);
7372
}
7473

7574
[Fact]
@@ -85,9 +84,9 @@ public void ParseTagReference()
8584
var reference = versionService.ConvertToOpenApiReference(input, referenceType);
8685

8786
// Assert
88-
reference.Type.Should().Be(referenceType);
89-
reference.ExternalResource.Should().BeNull();
90-
reference.Id.Should().Be(id);
87+
Assert.Equal(referenceType, reference.Type);
88+
Assert.Null(reference.ExternalResource);
89+
Assert.Equal(id, reference.Id);
9190
}
9291

9392
[Fact]
@@ -103,9 +102,9 @@ public void ParseSecuritySchemeReference()
103102
var reference = versionService.ConvertToOpenApiReference(input, referenceType);
104103

105104
// Assert
106-
reference.Type.Should().Be(referenceType);
107-
reference.ExternalResource.Should().BeNull();
108-
reference.Id.Should().Be(id);
105+
Assert.Equal(referenceType, reference.Type);
106+
Assert.Null(reference.ExternalResource);
107+
Assert.Equal(id, reference.Id);
109108
}
110109

111110
[Fact]
@@ -120,8 +119,8 @@ public void ParseLocalFileReference()
120119
var reference = versionService.ConvertToOpenApiReference(input, referenceType);
121120

122121
// Assert
123-
reference.Type.Should().Be(referenceType);
124-
reference.ExternalResource.Should().Be(input);
122+
Assert.Equal(referenceType, reference.Type);
123+
Assert.Equal(input, reference.ExternalResource);
125124
}
126125

127126
[Fact]
@@ -138,9 +137,9 @@ public void ParseExternalPathReference()
138137
var reference = versionService.ConvertToOpenApiReference(input, null);
139138

140139
// Assert
141-
reference.Type.Should().BeNull();
142-
reference.ExternalResource.Should().Be(externalResource);
143-
reference.Id.Should().Be(id);
140+
Assert.Null(reference.Type);
141+
Assert.Equal(externalResource, reference.ExternalResource);
142+
Assert.Equal(id, reference.Id);
144143
}
145144
}
146145
}

test/Microsoft.OpenApi.Readers.Tests/TestCustomExtension.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
// Licensed under the MIT license.
33

44
using System.Text.Json.Nodes;
5-
using FluentAssertions;
65
using Microsoft.OpenApi.Interfaces;
76
using Microsoft.OpenApi.Models;
87
using Microsoft.OpenApi.Reader;
@@ -44,9 +43,9 @@ public void ParseCustomExtension()
4443

4544
var fooExtension = actual.Document.Info.Extensions["x-foo"] as FooExtension;
4645

47-
fooExtension.Should().NotBeNull();
48-
fooExtension.Bar.Should().Be("hey");
49-
fooExtension.Baz.Should().Be("hi!");
46+
Assert.NotNull(fooExtension);
47+
Assert.Equal("hey", fooExtension.Bar);
48+
Assert.Equal("hi!", fooExtension.Baz);
5049
}
5150
}
5251

test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiContactTests.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// Copyright (c) Microsoft Corporation. All rights reserved.
22
// Licensed under the MIT license.
33

4-
using FluentAssertions;
54
using Microsoft.OpenApi.Models;
65
using Microsoft.OpenApi.Reader;
76
using Xunit;
@@ -26,15 +25,15 @@ public void ParseStringContactFragmentShouldSucceed()
2625
var contact = OpenApiModelFactory.Parse<OpenApiContact>(input, OpenApiSpecVersion.OpenApi2_0, out var diagnostic);
2726

2827
// Assert
29-
diagnostic.Should().BeEquivalentTo(new OpenApiDiagnostic());
28+
Assert.Equivalent(new OpenApiDiagnostic(), diagnostic);
3029

31-
contact.Should().BeEquivalentTo(
30+
Assert.Equivalent(
3231
new OpenApiContact
3332
{
3433
Email = "[email protected]",
3534
Name = "API Support",
3635
Url = new("http://www.swagger.io/support")
37-
});
36+
}, contact);
3837
}
3938
}
4039
}

test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiParameterTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public void ParseBodyParameterShouldSucceed()
3333
// Assert
3434
// Body parameter is currently not translated via LoadParameter.
3535
// This design may be revisited and this unit test may likely change.
36-
parameter.Should().BeNull();
36+
Assert.Null(parameter);
3737
}
3838

3939
[Fact]

test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiDocumentTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ public async Task ParseBasicDocumentWithMultipleServersShouldSucceed()
117117
var path = System.IO.Path.Combine(SampleFolderPath, "basicDocumentWithMultipleServers.yaml");
118118
var result = await OpenApiDocument.LoadAsync(path);
119119

120-
result.Diagnostic.Errors.Should().BeEmpty();
120+
Assert.Empty(result.Diagnostic.Errors);
121121
result.Document.Should().BeEquivalentTo(
122122
new OpenApiDocument
123123
{
@@ -1409,7 +1409,7 @@ public void ParseBasicDocumentWithServerVariableAndNoDefaultShouldFail()
14091409
public async Task ParseDocumentWithEmptyPathsSucceeds()
14101410
{
14111411
var result = await OpenApiDocument.LoadAsync(System.IO.Path.Combine(SampleFolderPath, "docWithEmptyPaths.yaml"));
1412-
result.Diagnostic.Errors.Should().BeEmpty();
1412+
Assert.Empty(result.Diagnostic.Errors);
14131413
}
14141414
}
14151415
}

test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiExampleTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public async Task ParseAdvancedExampleShouldSucceed()
7878
public async Task ParseExampleForcedStringSucceed()
7979
{
8080
var result = await OpenApiDocument.LoadAsync(Path.Combine(SampleFolderPath, "explicitString.yaml"));
81-
result.Diagnostic.Errors.Should().BeEmpty();
81+
Assert.Empty(result.Diagnostic.Errors);
8282
}
8383
}
8484
}

0 commit comments

Comments
 (0)