Skip to content

Commit 4e9c56a

Browse files
authored
Merge pull request #504 from AndrewRissing/CorrectSkippedUnitTests
Corrected expected ordering for skipped unit tests.
2 parents cb3c26b + 1a2a22a commit 4e9c56a

7 files changed

+281
-321
lines changed

test/Microsoft.OpenApi.Tests/Services/OpenApiComparerTestCases.cs

Lines changed: 212 additions & 212 deletions
Large diffs are not rendered by default.

test/Microsoft.OpenApi.Tests/Services/OpenApiComparerTests.cs

Lines changed: 1 addition & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
using System.Collections.Generic;
55
using System.Linq;
66
using FluentAssertions;
7-
using Microsoft.OpenApi.Any;
87
using Microsoft.OpenApi.Models;
98
using Microsoft.OpenApi.Services;
109
using Xunit;
@@ -15,51 +14,14 @@ namespace Microsoft.OpenApi.Tests.Services
1514
[Collection("DefaultSettings")]
1615
public class OpenApiComparerTests
1716
{
18-
public static OpenApiExample AdvancedExample = new OpenApiExample
19-
{
20-
Value = new OpenApiObject
21-
{
22-
["versions"] = new OpenApiArray
23-
{
24-
new OpenApiObject
25-
{
26-
["status"] = new OpenApiString("Status1"),
27-
["id"] = new OpenApiString("v1"),
28-
["links"] = new OpenApiArray
29-
{
30-
new OpenApiObject
31-
{
32-
["href"] = new OpenApiString("http://example.com/1"),
33-
["rel"] = new OpenApiString("sampleRel1")
34-
}
35-
}
36-
},
37-
38-
new OpenApiObject
39-
{
40-
["status"] = new OpenApiString("Status2"),
41-
["id"] = new OpenApiString("v2"),
42-
["links"] = new OpenApiArray
43-
{
44-
new OpenApiObject
45-
{
46-
["href"] = new OpenApiString("http://example.com/2"),
47-
["rel"] = new OpenApiString("sampleRel2")
48-
}
49-
}
50-
}
51-
}
52-
}
53-
};
54-
5517
private readonly ITestOutputHelper _output;
5618

5719
public OpenApiComparerTests(ITestOutputHelper output)
5820
{
5921
_output = output;
6022
}
6123

62-
[Theory(Skip = "Need to fix")]
24+
[Theory]
6325
[MemberData(
6426
nameof(OpenApiComparerTestCases.GetTestCasesForOpenApiComparerShouldSucceed),
6527
MemberType = typeof(OpenApiComparerTestCases))]
@@ -71,8 +33,6 @@ public void OpenApiComparerShouldSucceed(
7133
{
7234
_output.WriteLine(testCaseName);
7335

74-
new OpenApiExampleComparer().Compare(AdvancedExample, AdvancedExample,
75-
new ComparisonContext(new OpenApiComparerFactory(), new OpenApiDocument(), new OpenApiDocument()));
7636
var differences = OpenApiComparer.Compare(source, target).ToList();
7737
differences.Count().Should().Be(expectedDifferences.Count);
7838

test/Microsoft.OpenApi.Tests/Services/OpenApiEncodingComparerTests.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -246,14 +246,6 @@ public static IEnumerable<object[]> GetTestCasesForOpenApiEncodingComparerShould
246246
SourceValue = "image/png, image/jpeg"
247247
},
248248
new OpenApiDifference
249-
{
250-
Pointer = "#/style",
251-
OpenApiDifferenceOperation = OpenApiDifferenceOperation.Update,
252-
OpenApiComparedElementType = typeof(ParameterStyle),
253-
TargetValue = ParameterStyle.Form,
254-
SourceValue = ParameterStyle.Simple
255-
},
256-
new OpenApiDifference
257249
{
258250
Pointer = "#/explode",
259251
OpenApiDifferenceOperation = OpenApiDifferenceOperation.Update,
@@ -268,6 +260,14 @@ public static IEnumerable<object[]> GetTestCasesForOpenApiEncodingComparerShould
268260
OpenApiComparedElementType = typeof(bool?),
269261
TargetValue = false,
270262
SourceValue = true
263+
},
264+
new OpenApiDifference
265+
{
266+
Pointer = "#/style",
267+
OpenApiDifferenceOperation = OpenApiDifferenceOperation.Update,
268+
OpenApiComparedElementType = typeof(ParameterStyle),
269+
TargetValue = ParameterStyle.Form,
270+
SourceValue = ParameterStyle.Simple
271271
}
272272
}
273273
};
@@ -336,7 +336,7 @@ public static IEnumerable<object[]> GetTestCasesForOpenApiEncodingComparerShould
336336
}
337337

338338

339-
[Theory(Skip = "Need to fix")]
339+
[Theory]
340340
[MemberData(nameof(GetTestCasesForOpenApiEncodingComparerShouldSucceed))]
341341
public void OpenApiEncodingComparerShouldSucceed(
342342
string testCaseName,

test/Microsoft.OpenApi.Tests/Services/OpenApiInfoComparerTests.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -254,26 +254,26 @@ public static IEnumerable<object[]> GetTestCasesForOpenApiInfoComparerShouldSucc
254254
SourceValue = "Test description"
255255
},
256256
new OpenApiDifference
257-
{
258-
Pointer = "#/version",
259-
OpenApiDifferenceOperation = OpenApiDifferenceOperation.Update,
260-
OpenApiComparedElementType = typeof(string),
261-
TargetValue = "Test version updated",
262-
SourceValue = "Test version"
263-
},
264-
new OpenApiDifference
265257
{
266258
Pointer = "#/termsOfService",
267259
OpenApiDifferenceOperation = OpenApiDifferenceOperation.Update,
268260
OpenApiComparedElementType = typeof(Uri),
269261
TargetValue = new Uri("http://localhost/2"),
270262
SourceValue = new Uri("http://localhost/1")
263+
},
264+
new OpenApiDifference
265+
{
266+
Pointer = "#/version",
267+
OpenApiDifferenceOperation = OpenApiDifferenceOperation.Update,
268+
OpenApiComparedElementType = typeof(string),
269+
TargetValue = "Test version updated",
270+
SourceValue = "Test version"
271271
}
272272
}
273273
};
274274
}
275275

276-
[Theory(Skip = "Need to fix")]
276+
[Theory]
277277
[MemberData(nameof(GetTestCasesForOpenApiInfoComparerShouldSucceed))]
278278
public void OpenApiInfoComparerShouldSucceed(
279279
string testCaseName,

test/Microsoft.OpenApi.Tests/Services/OpenApiSecuritySchemeComparerTests.cs

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -129,14 +129,6 @@ public static IEnumerable<object[]> GetTestCasesForOpenApiSecuritySchemeComparer
129129
},
130130
new List<OpenApiDifference>
131131
{
132-
new OpenApiDifference
133-
{
134-
Pointer = "#/type",
135-
OpenApiDifferenceOperation = OpenApiDifferenceOperation.Update,
136-
OpenApiComparedElementType = typeof(SecuritySchemeType),
137-
SourceValue = SecuritySchemeType.ApiKey,
138-
TargetValue = SecuritySchemeType.Http
139-
},
140132
new OpenApiDifference
141133
{
142134
Pointer = "#/description",
@@ -146,6 +138,14 @@ public static IEnumerable<object[]> GetTestCasesForOpenApiSecuritySchemeComparer
146138
TargetValue = "Test Description Updated"
147139
},
148140
new OpenApiDifference
141+
{
142+
Pointer = "#/type",
143+
OpenApiDifferenceOperation = OpenApiDifferenceOperation.Update,
144+
OpenApiComparedElementType = typeof(SecuritySchemeType),
145+
SourceValue = SecuritySchemeType.ApiKey,
146+
TargetValue = SecuritySchemeType.Http
147+
},
148+
new OpenApiDifference
149149
{
150150
Pointer = "#/name",
151151
OpenApiDifferenceOperation = OpenApiDifferenceOperation.Update,
@@ -162,6 +162,14 @@ public static IEnumerable<object[]> GetTestCasesForOpenApiSecuritySchemeComparer
162162
TargetValue = ParameterLocation.Query
163163
},
164164
new OpenApiDifference
165+
{
166+
Pointer = "#/scheme",
167+
OpenApiDifferenceOperation = OpenApiDifferenceOperation.Update,
168+
OpenApiComparedElementType = typeof(string),
169+
SourceValue = null,
170+
TargetValue = "basic"
171+
},
172+
new OpenApiDifference
165173
{
166174
Pointer = "#/bearerFormat",
167175
OpenApiDifferenceOperation = OpenApiDifferenceOperation.Update,
@@ -176,14 +184,6 @@ public static IEnumerable<object[]> GetTestCasesForOpenApiSecuritySchemeComparer
176184
OpenApiComparedElementType = typeof(Uri),
177185
SourceValue = new Uri("http://localhost:1"),
178186
TargetValue = null
179-
},
180-
new OpenApiDifference
181-
{
182-
Pointer = "#/scheme",
183-
OpenApiDifferenceOperation = OpenApiDifferenceOperation.Update,
184-
OpenApiComparedElementType = typeof(string),
185-
SourceValue = null,
186-
TargetValue = "basic"
187187
}
188188
}
189189
};
@@ -259,31 +259,31 @@ public static IEnumerable<object[]> GetTestCasesForOpenApiSecuritySchemeComparer
259259
},
260260
new OpenApiDifference
261261
{
262-
Pointer = "#/flows/authorizationCode",
262+
Pointer = "#/flows/clientCredentials",
263263
OpenApiDifferenceOperation = OpenApiDifferenceOperation.Update,
264264
OpenApiComparedElementType = typeof(OpenApiOAuthFlow),
265-
SourceValue = new OpenApiOAuthFlow
265+
SourceValue = null,
266+
TargetValue = new OpenApiOAuthFlow
266267
{
267268
AuthorizationUrl = new Uri("http://localhost/2")
268-
},
269-
TargetValue = null
269+
}
270270
},
271271
new OpenApiDifference
272272
{
273-
Pointer = "#/flows/clientCredentials",
273+
Pointer = "#/flows/authorizationCode",
274274
OpenApiDifferenceOperation = OpenApiDifferenceOperation.Update,
275275
OpenApiComparedElementType = typeof(OpenApiOAuthFlow),
276-
SourceValue = null,
277-
TargetValue = new OpenApiOAuthFlow
276+
SourceValue = new OpenApiOAuthFlow
278277
{
279278
AuthorizationUrl = new Uri("http://localhost/2")
280-
}
279+
},
280+
TargetValue = null
281281
}
282282
}
283283
};
284284
}
285285

286-
[Theory(Skip = "Need to fix")]
286+
[Theory]
287287
[MemberData(nameof(GetTestCasesForOpenApiSecuritySchemeComparerShouldSucceed))]
288288
public void OpenApiSecuritySchemeComparerShouldSucceed(
289289
string testCaseName,

test/Microsoft.OpenApi.Tests/Services/OpenApiServersComparerTests.cs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -390,13 +390,13 @@ public static IEnumerable<object[]> GetTestCasesForOpenApiServersComparerShouldS
390390
new OpenApiDifference
391391
{
392392
Pointer = "#/0",
393-
OpenApiDifferenceOperation = OpenApiDifferenceOperation.Add,
393+
OpenApiDifferenceOperation = OpenApiDifferenceOperation.Remove,
394394
OpenApiComparedElementType = typeof(OpenApiServer),
395-
SourceValue = null,
396-
TargetValue = new OpenApiServer
395+
TargetValue = null,
396+
SourceValue = new OpenApiServer
397397
{
398398
Description = "description1",
399-
Url = "https://{username}.example.com:{port}/test",
399+
Url = "https://{username}.example.com:{port}/{basePath}",
400400
Variables = new Dictionary<string, OpenApiServerVariable>
401401
{
402402
["username"] = new OpenApiServerVariable
@@ -423,14 +423,14 @@ public static IEnumerable<object[]> GetTestCasesForOpenApiServersComparerShouldS
423423
},
424424
new OpenApiDifference
425425
{
426-
Pointer = "#/1",
426+
Pointer = "#/0",
427427
OpenApiDifferenceOperation = OpenApiDifferenceOperation.Add,
428428
OpenApiComparedElementType = typeof(OpenApiServer),
429429
SourceValue = null,
430430
TargetValue = new OpenApiServer
431431
{
432-
Description = "description3",
433-
Url = "https://{username}.example.com:{port}/{basePath}/test",
432+
Description = "description1",
433+
Url = "https://{username}.example.com:{port}/test",
434434
Variables = new Dictionary<string, OpenApiServerVariable>
435435
{
436436
["username"] = new OpenApiServerVariable
@@ -457,14 +457,14 @@ public static IEnumerable<object[]> GetTestCasesForOpenApiServersComparerShouldS
457457
},
458458
new OpenApiDifference
459459
{
460-
Pointer = "#/0",
461-
OpenApiDifferenceOperation = OpenApiDifferenceOperation.Remove,
460+
Pointer = "#/1",
461+
OpenApiDifferenceOperation = OpenApiDifferenceOperation.Add,
462462
OpenApiComparedElementType = typeof(OpenApiServer),
463-
TargetValue = null,
464-
SourceValue = new OpenApiServer
463+
SourceValue = null,
464+
TargetValue = new OpenApiServer
465465
{
466-
Description = "description1",
467-
Url = "https://{username}.example.com:{port}/{basePath}",
466+
Description = "description3",
467+
Url = "https://{username}.example.com:{port}/{basePath}/test",
468468
Variables = new Dictionary<string, OpenApiServerVariable>
469469
{
470470
["username"] = new OpenApiServerVariable
@@ -493,7 +493,7 @@ public static IEnumerable<object[]> GetTestCasesForOpenApiServersComparerShouldS
493493
};
494494
}
495495

496-
[Theory(Skip = "Need to fix")]
496+
[Theory]
497497
[MemberData(nameof(GetTestCasesForOpenApiServersComparerShouldSucceed))]
498498
public void OpenApiServersComparerShouldSucceed(
499499
string testCaseName,

test/Microsoft.OpenApi.Tests/Services/OpenApiTagComparerTests.cs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -246,41 +246,41 @@ public static IEnumerable<object[]> GetTestCasesForOpenApiTagComparerShouldSucce
246246
{
247247
new OpenApiDifference
248248
{
249-
Pointer = "#/description",
249+
Pointer = "#/externalDocs/description",
250250
OpenApiDifferenceOperation = OpenApiDifferenceOperation.Update,
251251
OpenApiComparedElementType = typeof(string),
252252
SourceValue = "test description",
253253
TargetValue = "test description updated"
254254
},
255255
new OpenApiDifference
256256
{
257-
Pointer = "#/name",
257+
Pointer = "#/externalDocs/url",
258258
OpenApiDifferenceOperation = OpenApiDifferenceOperation.Update,
259-
OpenApiComparedElementType = typeof(string),
260-
SourceValue = "test name",
261-
TargetValue = "test name updated"
259+
OpenApiComparedElementType = typeof(Uri),
260+
SourceValue = new Uri("http://localhost/doc"),
261+
TargetValue = new Uri("http://localhost/updated")
262262
},
263263
new OpenApiDifference
264264
{
265-
Pointer = "#/externalDocs/description",
265+
Pointer = "#/description",
266266
OpenApiDifferenceOperation = OpenApiDifferenceOperation.Update,
267267
OpenApiComparedElementType = typeof(string),
268268
SourceValue = "test description",
269269
TargetValue = "test description updated"
270270
},
271271
new OpenApiDifference
272272
{
273-
Pointer = "#/externalDocs/url",
273+
Pointer = "#/name",
274274
OpenApiDifferenceOperation = OpenApiDifferenceOperation.Update,
275-
OpenApiComparedElementType = typeof(Uri),
276-
SourceValue = new Uri("http://localhost/doc"),
277-
TargetValue = new Uri("http://localhost/updated")
275+
OpenApiComparedElementType = typeof(string),
276+
SourceValue = "test name",
277+
TargetValue = "test name updated"
278278
}
279279
}
280280
};
281281
}
282282

283-
[Theory(Skip = "Need to fix")]
283+
[Theory]
284284
[MemberData(nameof(GetTestCasesForOpenApiTagComparerShouldSucceed))]
285285
public void OpenApiTagServerVariableComparerShouldSucceed(
286286
string testCaseName,

0 commit comments

Comments
 (0)