Skip to content

Commit 481d3bc

Browse files
committed
Fix other tests
1 parent 78bcdd4 commit 481d3bc

File tree

2 files changed

+13
-9
lines changed

2 files changed

+13
-9
lines changed

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

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,11 @@ public void ValidateRequiredIsTrueWhenInIsPathInParameter()
4848
};
4949

5050
// Act
51-
var errors = parameter.Validate(ValidationRuleSet.GetDefaultRuleSet());
52-
51+
var validator = new OpenApiValidator(ValidationRuleSet.GetDefaultRuleSet());
52+
validator.Enter("{name}");
53+
var walker = new OpenApiWalker(validator);
54+
walker.Walk(parameter);
55+
var errors = validator.Errors;
5356
// Assert
5457
errors.Should().NotBeEmpty();
5558
errors.Select(e => e.Message).Should().BeEquivalentTo(new[]
@@ -77,6 +80,7 @@ public void ValidateExampleShouldNotHaveDataTypeMismatchForSimpleSchema()
7780

7881
// Act
7982
var validator = new OpenApiValidator(ValidationRuleSet.GetDefaultRuleSet());
83+
validator.Enter("{parameter1}");
8084
var walker = new OpenApiWalker(validator);
8185
walker.Walk(parameter);
8286

@@ -91,7 +95,7 @@ public void ValidateExampleShouldNotHaveDataTypeMismatchForSimpleSchema()
9195
});
9296
errors.Select(e => e.Pointer).Should().BeEquivalentTo(new[]
9397
{
94-
"#/example",
98+
"#/{parameter1}/example",
9599
});
96100
}
97101

@@ -150,6 +154,7 @@ public void ValidateExamplesShouldNotHaveDataTypeMismatchForSimpleSchema()
150154

151155
// Act
152156
var validator = new OpenApiValidator(ValidationRuleSet.GetDefaultRuleSet());
157+
validator.Enter("{parameter1}");
153158
var walker = new OpenApiWalker(validator);
154159
walker.Walk(parameter);
155160

@@ -168,9 +173,9 @@ public void ValidateExamplesShouldNotHaveDataTypeMismatchForSimpleSchema()
168173
{
169174
// #enum/0 is not an error since the spec allows
170175
// representing an object using a string.
171-
"#/examples/example1/value/y",
172-
"#/examples/example1/value/z",
173-
"#/examples/example2/value"
176+
"#/{parameter1}/examples/example1/value/y",
177+
"#/{parameter1}/examples/example1/value/z",
178+
"#/{parameter1}/examples/example2/value"
174179
});
175180
}
176181

@@ -193,7 +198,6 @@ public void PathParameterNotInThePathShouldReturnAnError()
193198

194199
// Act
195200
var validator = new OpenApiValidator(ValidationRuleSet.GetDefaultRuleSet());
196-
validator.Enter("1");
197201

198202
var walker = new OpenApiWalker(validator);
199203
walker.Walk(parameter);
@@ -209,7 +213,7 @@ public void PathParameterNotInThePathShouldReturnAnError()
209213
});
210214
errors.Select(e => e.Pointer).Should().BeEquivalentTo(new[]
211215
{
212-
"#/1/in"
216+
"#/in"
213217
});
214218
}
215219

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public void DefaultRuleSetPropertyReturnsTheCorrectRules()
4343
Assert.NotEmpty(rules);
4444

4545
// Update the number if you add new default rule(s).
46-
Assert.Equal(21, rules.Count);
46+
Assert.Equal(22, rules.Count);
4747
}
4848
}
4949
}

0 commit comments

Comments
 (0)