Skip to content

Commit ad3b65d

Browse files
committed
clean up tests and update public API interface
1 parent 9bf3f08 commit ad3b65d

File tree

6 files changed

+13
-133
lines changed

6 files changed

+13
-133
lines changed

test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1682,11 +1682,6 @@ namespace Microsoft.OpenApi.Validations.Rules
16821682
public static Microsoft.OpenApi.Validations.ValidationRule<Microsoft.OpenApi.Models.OpenApiExternalDocs> UrlIsRequired { get; }
16831683
}
16841684
[Microsoft.OpenApi.Validations.Rules.OpenApiRule]
1685-
public static class OpenApiHeaderRules
1686-
{
1687-
public static Microsoft.OpenApi.Validations.ValidationRule<Microsoft.OpenApi.Models.OpenApiHeader> HeaderMismatchedDataType { get; }
1688-
}
1689-
[Microsoft.OpenApi.Validations.Rules.OpenApiRule]
16901685
public static class OpenApiInfoRules
16911686
{
16921687
public static Microsoft.OpenApi.Validations.ValidationRule<Microsoft.OpenApi.Models.OpenApiInfo> InfoRequiredFields { get; }
@@ -1697,19 +1692,13 @@ namespace Microsoft.OpenApi.Validations.Rules
16971692
public static Microsoft.OpenApi.Validations.ValidationRule<Microsoft.OpenApi.Models.OpenApiLicense> LicenseRequiredFields { get; }
16981693
}
16991694
[Microsoft.OpenApi.Validations.Rules.OpenApiRule]
1700-
public static class OpenApiMediaTypeRules
1701-
{
1702-
public static Microsoft.OpenApi.Validations.ValidationRule<Microsoft.OpenApi.Models.OpenApiMediaType> MediaTypeMismatchedDataType { get; }
1703-
}
1704-
[Microsoft.OpenApi.Validations.Rules.OpenApiRule]
17051695
public static class OpenApiOAuthFlowRules
17061696
{
17071697
public static Microsoft.OpenApi.Validations.ValidationRule<Microsoft.OpenApi.Models.OpenApiOAuthFlow> OAuthFlowRequiredFields { get; }
17081698
}
17091699
[Microsoft.OpenApi.Validations.Rules.OpenApiRule]
17101700
public static class OpenApiParameterRules
17111701
{
1712-
public static Microsoft.OpenApi.Validations.ValidationRule<Microsoft.OpenApi.Models.OpenApiParameter> ParameterMismatchedDataType { get; }
17131702
public static Microsoft.OpenApi.Validations.ValidationRule<Microsoft.OpenApi.Models.OpenApiParameter> ParameterRequiredFields { get; }
17141703
public static Microsoft.OpenApi.Validations.ValidationRule<Microsoft.OpenApi.Models.OpenApiParameter> PathParameterShouldBeInThePath { get; }
17151704
public static Microsoft.OpenApi.Validations.ValidationRule<Microsoft.OpenApi.Models.OpenApiParameter> RequiredMustBeTrueWhenInIsPath { get; }
@@ -1739,7 +1728,6 @@ namespace Microsoft.OpenApi.Validations.Rules
17391728
[Microsoft.OpenApi.Validations.Rules.OpenApiRule]
17401729
public static class OpenApiSchemaRules
17411730
{
1742-
public static Microsoft.OpenApi.Validations.ValidationRule<Microsoft.OpenApi.Models.OpenApiSchema> SchemaMismatchedDataType { get; }
17431731
public static Microsoft.OpenApi.Validations.ValidationRule<Microsoft.OpenApi.Models.OpenApiSchema> ValidateSchemaDiscriminator { get; }
17441732
public static bool TraverseSchemaElements(string discriminatorName, System.Collections.Generic.IList<Microsoft.OpenApi.Models.OpenApiSchema> childSchema) { }
17451733
public static bool ValidateChildSchemaAgainstDiscriminator(Microsoft.OpenApi.Models.OpenApiSchema schema, string discriminatorName) { }

test/Microsoft.OpenApi.Tests/Validations/OpenApiHeaderValidationTests.cs

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,7 @@ public void ValidateExampleShouldNotHaveDataTypeMismatchForSimpleSchema()
4040
var result = !warnings.Any();
4141

4242
// Assert
43-
result.Should().BeFalse();
44-
warnings.Select(e => e.Message).Should().BeEquivalentTo(new[]
45-
{
46-
RuleHelpers.DataTypeMismatchedErrorMessage
47-
});
48-
warnings.Select(e => e.Pointer).Should().BeEquivalentTo(new[]
49-
{
50-
"#/example",
51-
});
43+
result.Should().BeTrue();
5244
}
5345

5446
[Fact]
@@ -107,21 +99,7 @@ public void ValidateExamplesShouldNotHaveDataTypeMismatchForSimpleSchema()
10799
var result = !warnings.Any();
108100

109101
// Assert
110-
result.Should().BeFalse();
111-
warnings.Select(e => e.Message).Should().BeEquivalentTo(new[]
112-
{
113-
RuleHelpers.DataTypeMismatchedErrorMessage,
114-
RuleHelpers.DataTypeMismatchedErrorMessage,
115-
RuleHelpers.DataTypeMismatchedErrorMessage,
116-
});
117-
warnings.Select(e => e.Pointer).Should().BeEquivalentTo(new[]
118-
{
119-
// #enum/0 is not an error since the spec allows
120-
// representing an object using a string.
121-
"#/examples/example1/value/y",
122-
"#/examples/example1/value/z",
123-
"#/examples/example2/value"
124-
});
102+
result.Should().BeTrue();
125103
}
126104
}
127105
}

test/Microsoft.OpenApi.Tests/Validations/OpenApiMediaTypeValidationTests.cs

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,7 @@ public void ValidateExampleShouldNotHaveDataTypeMismatchForSimpleSchema()
3939
var result = !warnings.Any();
4040

4141
// Assert
42-
result.Should().BeFalse();
43-
warnings.Select(e => e.Message).Should().BeEquivalentTo(new[]
44-
{
45-
RuleHelpers.DataTypeMismatchedErrorMessage
46-
});
47-
warnings.Select(e => e.Pointer).Should().BeEquivalentTo(new[]
48-
{
49-
"#/example",
50-
});
42+
result.Should().BeTrue();
5143
}
5244

5345
[Fact]
@@ -106,21 +98,7 @@ public void ValidateExamplesShouldNotHaveDataTypeMismatchForSimpleSchema()
10698
var result = !warnings.Any();
10799

108100
// Assert
109-
result.Should().BeFalse();
110-
warnings.Select(e => e.Message).Should().BeEquivalentTo(new[]
111-
{
112-
RuleHelpers.DataTypeMismatchedErrorMessage,
113-
RuleHelpers.DataTypeMismatchedErrorMessage,
114-
RuleHelpers.DataTypeMismatchedErrorMessage,
115-
});
116-
warnings.Select(e => e.Pointer).Should().BeEquivalentTo(new[]
117-
{
118-
// #enum/0 is not an error since the spec allows
119-
// representing an object using a string.
120-
"#/examples/example1/value/y",
121-
"#/examples/example1/value/z",
122-
"#/examples/example2/value"
123-
});
101+
result.Should().BeTrue();
124102
}
125103
}
126104
}

test/Microsoft.OpenApi.Tests/Validations/OpenApiParameterValidationTests.cs

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -88,15 +88,7 @@ public void ValidateExampleShouldNotHaveDataTypeMismatchForSimpleSchema()
8888
var result = !warnings.Any();
8989

9090
// Assert
91-
result.Should().BeFalse();
92-
warnings.Select(e => e.Message).Should().BeEquivalentTo(new[]
93-
{
94-
RuleHelpers.DataTypeMismatchedErrorMessage
95-
});
96-
warnings.Select(e => e.Pointer).Should().BeEquivalentTo(new[]
97-
{
98-
"#/{parameter1}/example",
99-
});
91+
result.Should().BeTrue();
10092
}
10193

10294
[Fact]
@@ -158,21 +150,7 @@ public void ValidateExamplesShouldNotHaveDataTypeMismatchForSimpleSchema()
158150
var result = !warnings.Any();
159151

160152
// Assert
161-
result.Should().BeFalse();
162-
warnings.Select(e => e.Message).Should().BeEquivalentTo(new[]
163-
{
164-
RuleHelpers.DataTypeMismatchedErrorMessage,
165-
RuleHelpers.DataTypeMismatchedErrorMessage,
166-
RuleHelpers.DataTypeMismatchedErrorMessage,
167-
});
168-
warnings.Select(e => e.Pointer).Should().BeEquivalentTo(new[]
169-
{
170-
// #enum/0 is not an error since the spec allows
171-
// representing an object using a string.
172-
"#/{parameter1}/examples/example1/value/y",
173-
"#/{parameter1}/examples/example1/value/z",
174-
"#/{parameter1}/examples/example2/value"
175-
});
153+
result.Should().BeTrue();
176154
}
177155

178156
[Fact]

test/Microsoft.OpenApi.Tests/Validations/OpenApiSchemaValidationTests.cs

Lines changed: 4 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,7 @@ public void ValidateDefaultShouldNotHaveDataTypeMismatchForSimpleSchema()
3939
var result = !warnings.Any();
4040

4141
// Assert
42-
result.Should().BeFalse();
43-
warnings.Select(e => e.Message).Should().BeEquivalentTo(new[]
44-
{
45-
RuleHelpers.DataTypeMismatchedErrorMessage
46-
});
47-
warnings.Select(e => e.Pointer).Should().BeEquivalentTo(new[]
48-
{
49-
"#/default",
50-
});
42+
result.Should().BeTrue();
5143
}
5244

5345
[Fact]
@@ -72,15 +64,7 @@ public void ValidateExampleAndDefaultShouldNotHaveDataTypeMismatchForSimpleSchem
7264
var expectedWarnings = warnings.Select(e => e.Message).ToList();
7365

7466
// Assert
75-
result.Should().BeFalse();
76-
warnings.Select(e => e.Message).Should().BeEquivalentTo(new[]
77-
{
78-
RuleHelpers.DataTypeMismatchedErrorMessage
79-
});
80-
warnings.Select(e => e.Pointer).Should().BeEquivalentTo(new[]
81-
{
82-
"#/example",
83-
});
67+
result.Should().BeTrue();
8468
}
8569

8670
[Fact]
@@ -122,21 +106,7 @@ public void ValidateEnumShouldNotHaveDataTypeMismatchForSimpleSchema()
122106
var result = !warnings.Any();
123107

124108
// Assert
125-
result.Should().BeFalse();
126-
warnings.Select(e => e.Message).Should().BeEquivalentTo(new[]
127-
{
128-
RuleHelpers.DataTypeMismatchedErrorMessage,
129-
RuleHelpers.DataTypeMismatchedErrorMessage,
130-
RuleHelpers.DataTypeMismatchedErrorMessage,
131-
});
132-
warnings.Select(e => e.Pointer).Should().BeEquivalentTo(new[]
133-
{
134-
// #enum/0 is not an error since the spec allows
135-
// representing an object using a string.
136-
"#/enum/1/y",
137-
"#/enum/1/z",
138-
"#/enum/2"
139-
});
109+
result.Should().BeTrue();
140110
}
141111

142112
[Fact]
@@ -212,19 +182,7 @@ public void ValidateDefaultShouldNotHaveDataTypeMismatchForComplexSchema()
212182
bool result = !warnings.Any();
213183

214184
// Assert
215-
result.Should().BeFalse();
216-
warnings.Select(e => e.Message).Should().BeEquivalentTo(new[]
217-
{
218-
RuleHelpers.DataTypeMismatchedErrorMessage,
219-
RuleHelpers.DataTypeMismatchedErrorMessage,
220-
RuleHelpers.DataTypeMismatchedErrorMessage
221-
});
222-
warnings.Select(e => e.Pointer).Should().BeEquivalentTo(new[]
223-
{
224-
"#/default/property1/2",
225-
"#/default/property2/0",
226-
"#/default/property2/1/z"
227-
});
185+
result.Should().BeTrue();
228186
}
229187

230188
[Fact]

test/Microsoft.OpenApi.Tests/Validations/ValidationRuleSetTests.cs

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

44
using System;
@@ -55,8 +55,8 @@ public void RuleSetConstructorsReturnsTheCorrectRules()
5555
Assert.Empty(ruleSet_4.Rules);
5656

5757
// Update the number if you add new default rule(s).
58-
Assert.Equal(23, ruleSet_1.Rules.Count);
59-
Assert.Equal(23, ruleSet_2.Rules.Count);
58+
Assert.Equal(19, ruleSet_1.Rules.Count);
59+
Assert.Equal(19, ruleSet_2.Rules.Count);
6060
Assert.Equal(3, ruleSet_3.Rules.Count);
6161
}
6262

0 commit comments

Comments
 (0)