Skip to content

Commit

Permalink
More tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
JohanLarsson committed Mar 22, 2022
1 parent 3e0d5fe commit 24bb5c2
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions Gu.Roslyn.Asserts.Tests/RoslynAssertTests/FixAll.Fail.cs
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,48 @@ class C
CodeAssert.AreEqual(expected, exception.Message);
}

[Test]
public static void WhenFixDoesNotDoAnything()
{
var before = @"
namespace N
{
class C
{
private readonly int ↓_f = 1;
}
}";

var after = @"
namespace N
{
class C
{
private readonly int _f = 1;
}
}";
var analyzer = new FieldNameMustNotBeginWithUnderscore();
var fix = new EmptyFix();
var exception = Assert.Throws<AssertException>(() => RoslynAssert.FixAll(analyzer, fix, before, after));
var expected = @"The fixed code by EmptyFix contains compiler diagnostic.
- fix the code used in the test
- suppress the warning in the test code using for example pragma
- suppress the warning by providing Settings to the assert.
CS0414 The field 'C._f' is assigned but its value is never used
at line 5 and character 29 in file C.cs | private readonly int ↓_f = 1;
First source file with diagnostic is:
namespace N
{
class C
{
private readonly int _f = 1;
}
}
";
CodeAssert.AreEqual(expected, exception.Message);
}

[Test]
public static void DuplicateId()
{
Expand Down

0 comments on commit 24bb5c2

Please sign in to comment.