Skip to content

Commit aebee6f

Browse files
committed
Add the test cases for ValidationRuleSet
1 parent 2e7e2dd commit aebee6f

File tree

3 files changed

+43
-2
lines changed

3 files changed

+43
-2
lines changed

src/Microsoft.OpenApi/Validations/ValidationRule.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
using System.Diagnostics;
66
using Microsoft.OpenApi.Interfaces;
77

8-
namespace Microsoft.OpenApi.Validations.Rules
8+
namespace Microsoft.OpenApi.Validations
99
{
1010
/// <summary>
1111
/// Class containing validation rule logic.

src/Microsoft.OpenApi/Validations/ValidationRuleSet.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@
88
using System.Collections.Generic;
99
using Microsoft.OpenApi.Exceptions;
1010
using Microsoft.OpenApi.Properties;
11+
using Microsoft.OpenApi.Validations.Rules;
1112

12-
namespace Microsoft.OpenApi.Validations.Rules
13+
namespace Microsoft.OpenApi.Validations
1314
{
1415
/// <summary>
1516
/// The rule set of the validation.
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the MIT license.
3+
4+
using System.Linq;
5+
using Xunit;
6+
7+
namespace Microsoft.OpenApi.Validations.Tests
8+
{
9+
public class ValidationRuleSetTests
10+
{
11+
[Fact]
12+
public void DefaultRuleSetReturnsTheCorrectRules()
13+
{
14+
// Arrange
15+
var ruleSet = new ValidationRuleSet();
16+
17+
// Act
18+
var rules = ruleSet.Rules;
19+
20+
// Assert
21+
Assert.NotNull(rules);
22+
Assert.Empty(rules);
23+
}
24+
25+
[Fact]
26+
public void DefaultRuleSetPropertyReturnsTheCorrectRules()
27+
{
28+
// Arrange & Act
29+
var ruleSet = ValidationRuleSet.DefaultRuleSet;
30+
Assert.NotNull(ruleSet); // guard
31+
32+
var rules = ruleSet.Rules;
33+
34+
// Assert
35+
Assert.NotNull(rules);
36+
Assert.NotEmpty(rules);
37+
Assert.Equal(13, rules.ToList().Count); // please update the number if you add new rule.
38+
}
39+
}
40+
}

0 commit comments

Comments
 (0)