Skip to content

Commit

Permalink
review
Browse files Browse the repository at this point in the history
  • Loading branch information
louis-z committed Dec 30, 2023
1 parent 2353664 commit 4f1d822
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,12 @@ public ProjectBuilder ShouldReportDiagnosticWithMessage(string message)

public ProjectBuilder ShouldFixCodeWith(string codeFix)
{
return ShouldFixCodeWith(index: null, codeFix ?? SourceCode);
return ShouldFixCodeWith(index: null, codeFix);
}

public ProjectBuilder ShouldFixCodeWithOriginalCode()
{
return ShouldFixCodeWith(index: null, SourceCode);
}

public ProjectBuilder ShouldFixCodeWith(int? index, string codeFix)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,19 @@ private static ProjectBuilder CreateProjectBuilder()

private static Task Assert(string sourceCode, string fix = null)
{
return CreateProjectBuilder()
.WithSourceCode(sourceCode)
.ShouldFixCodeWith(fix)
.ValidateAsync();
var projectBuilder = CreateProjectBuilder()
.WithSourceCode(sourceCode);

if (fix is null)
{
projectBuilder.ShouldFixCodeWithOriginalCode();
}
else
{
projectBuilder.ShouldFixCodeWith(fix);
}

return projectBuilder.ValidateAsync();
}

[Fact]
Expand Down Expand Up @@ -51,7 +60,7 @@ public void MyTest()
}
""");
}

[Fact]
public Task Assert_Inconclusive_NoReport()
{
Expand All @@ -69,7 +78,7 @@ public void MyTest()
}
""");
}

[Fact]
public Task Assert_Ignore_NoReport()
{
Expand All @@ -87,7 +96,7 @@ public void MyTest()
}
""");
}

[Fact]
public Task Assert_Fail_ExcludedFromOptions()
{
Expand All @@ -107,7 +116,7 @@ public void MyTest()
.AddAnalyzerConfiguration("mfa_excluded_methods", "M:NUnit.Framework.Assert.Fail")
.ValidateAsync();
}

[Fact]
public Task Assert_Fail_String_ExcludedFromOptions()
{
Expand All @@ -127,7 +136,7 @@ public void MyTest()
.AddAnalyzerConfiguration("mfa_excluded_methods", "M:NUnit.Framework.Assert.Fail(System.String)")
.ValidateAsync();
}

[Fact]
public Task Assert_MultiMethods_ExcludedFromOptions()
{
Expand Down Expand Up @@ -317,7 +326,7 @@ public void MyTest()
[InlineData(@"Assert.AreEqual(0d, (double?)null, delta: 2d)", @"((double?)null).Should().BeApproximately(0d, 2d)")]
[InlineData(@"Assert.AreEqual(0d, (double?)null, delta: 2d, ""because"")", @"((double?)null).Should().BeApproximately(0d, 2d, ""because"")")]
[InlineData(@"Assert.AreEqual(0d, (double?)null, delta: 2d, ""because"", 1, 2)", @"((double?)null).Should().BeApproximately(0d, 2d, ""because"", 1, 2)")]

[InlineData(@"Assert.AreEqual(0f, (float?)null, delta: 0.1f)", @"((float?)null).Should().BeApproximately(0f, 0.1f)")]
[InlineData(@"Assert.AreEqual(0f, 1f, delta: 0.1f)", @"1f.Should().BeApproximately(0f, 0.1f)")]

Expand Down

0 comments on commit 4f1d822

Please sign in to comment.