Skip to content

Commit

Permalink
SE UTs: Replace ValidateTag with TagValue (#7236)
Browse files Browse the repository at this point in the history
  • Loading branch information
pavel-mikula-sonarsource authored May 23, 2023
1 parent 91059f8 commit 030173b
Show file tree
Hide file tree
Showing 14 changed files with 341 additions and 337 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -625,7 +625,7 @@ public void Binary_NullableRelationalNonNull_SetsObjectConstraint_CS(string expr
validator.ValidateContainsOperation(OperationKind.Binary);
validator.ValidateTag("If", x => x.HasConstraint(ObjectConstraint.NotNull).Should().BeTrue("arg comparison true, hence non-null"));
validator.ValidateTag("If", x => x.HasConstraint<NumberConstraint>().Should().BeTrue("arg inferred a value from the comparison"));
validator.ValidateTag("Else", x => x.Should().HaveNoConstraints("arg either null or comparison false"));
validator.TagValue("Else").Should().HaveNoConstraints("arg either null or comparison false");
}

[DataTestMethod]
Expand All @@ -641,7 +641,7 @@ public void Binary_StringConcatenation_Binary_CS(string expression)
""";
var validator = SETestContext.CreateCS(code).Validator;
validator.ValidateContainsOperation(OperationKind.Binary);
validator.ValidateTag("S", x => x.Should().HaveNoConstraints()); // FIXME: s is not null here (https://github.com/SonarSource/sonar-dotnet/issues/7111)
validator.TagValue("S").Should().HaveNoConstraints(); // FIXME: s is not null here (https://github.com/SonarSource/sonar-dotnet/issues/7111)
}

[DataTestMethod]
Expand All @@ -657,7 +657,7 @@ public void Binary_StringConcatenation_Compund_CS(string expression)
""";
var validator = SETestContext.CreateCS(code).Validator;
validator.ValidateContainsOperation(OperationKind.Binary);
validator.ValidateTag("S", x => x.Should().HaveOnlyConstraint(ObjectConstraint.Null)); // FIXME: s is not null here (https://github.com/SonarSource/sonar-dotnet/issues/7111)
validator.TagValue("S").Should().HaveOnlyConstraint(ObjectConstraint.Null); // FIXME: s is not null here (https://github.com/SonarSource/sonar-dotnet/issues/7111)
}

[DataTestMethod]
Expand All @@ -680,7 +680,7 @@ public void Binary_NumberLiteral_SetsBoolConstraint_IsTrue(string value, string
Tag("Result", result);
""";
var validator = SETestContext.CreateCS(code).Validator;
validator.ValidateTag("Result", x => x.Should().HaveOnlyConstraints(ObjectConstraint.NotNull, BoolConstraint.True));
validator.TagValue("Result").Should().HaveOnlyConstraints(ObjectConstraint.NotNull, BoolConstraint.True);
}

[DataTestMethod]
Expand All @@ -700,7 +700,7 @@ public void Binary_NumberLiteral_SetsBoolConstraint_IsFalse(string value, string
Tag("Result", result);
""";
var validator = SETestContext.CreateCS(code, "int arg").Validator;
validator.ValidateTag("Result", x => x.Should().HaveOnlyConstraints(ObjectConstraint.NotNull, BoolConstraint.False));
validator.TagValue("Result").Should().HaveOnlyConstraints(ObjectConstraint.NotNull, BoolConstraint.False);
}

[DataTestMethod]
Expand Down Expand Up @@ -759,7 +759,7 @@ public void Binary_PlusAndMinus(string expression, int expected)
Tag("Value", value);
""";
var validator = SETestContext.CreateCS(code).Validator;
validator.ValidateTag("Value", x => x.Should().HaveOnlyConstraints(ObjectConstraint.NotNull, NumberConstraint.From(expected)));
validator.TagValue("Value").Should().HaveOnlyConstraints(ObjectConstraint.NotNull, NumberConstraint.From(expected));
}

[DataTestMethod]
Expand All @@ -781,7 +781,7 @@ public void Binary_Multiplication_SingleValue(int left, int right, int expected)
var value = left * right;
Tag("Value", value);
""";
SETestContext.CreateCS(code).Validator.ValidateTag("Value", x => x.Should().HaveOnlyConstraints(ObjectConstraint.NotNull, NumberConstraint.From(expected)));
SETestContext.CreateCS(code).Validator.TagValue("Value").Should().HaveOnlyConstraints(ObjectConstraint.NotNull, NumberConstraint.From(expected));
}

[DataTestMethod]
Expand Down Expand Up @@ -819,7 +819,7 @@ public void Binary_Multiplication_Range(string expression, int? expectedMin, int
}
""";
var validator = SETestContext.CreateCS(code, "int i, int j").Validator;
validator.ValidateTag("Value", x => x.Should().HaveOnlyConstraints(ObjectConstraint.NotNull, NumberConstraint.From(expectedMin, expectedMax)));
validator.TagValue("Value").Should().HaveOnlyConstraints(ObjectConstraint.NotNull, NumberConstraint.From(expectedMin, expectedMax));
}

[DataTestMethod]
Expand Down Expand Up @@ -879,6 +879,6 @@ public void Binary_BitAnd_Range(string expression, int? expectedMin, int? expect
}
""";
var validator = SETestContext.CreateCS(code, "int i, int j").Validator;
validator.ValidateTag("Value", x => x.Should().HaveOnlyConstraints(ObjectConstraint.NotNull, NumberConstraint.From(expectedMin, expectedMax)));
validator.TagValue("Value").Should().HaveOnlyConstraints(ObjectConstraint.NotNull, NumberConstraint.From(expectedMin, expectedMax));
}
}
Loading

0 comments on commit 030173b

Please sign in to comment.