fluentassertions.analyzers
fluentassertions.analyzers copied to clipboard
Suggestions to use fluent assertions instead of MSTest Asserts do not work if Assert is not on the top level of nesting in a test method
Description
Newly added functionality enabling easy move from MSTest Asserts to fluent assertions does not work if Assert is not on the top level of nesting in a test method.
Complete minimal example reproducing the issue
This will get a suggestion:
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace TestProject1
{
[TestClass]
public class UnitTest1
{
[TestMethod]
public void TestMethod1()
{
Assert.AreEqual(1, 1);
}
}
}
But this will not:
namespace TestProject1
{
using Microsoft.VisualStudio.TestTools.UnitTesting;
[TestClass]
public class UnitTest1
{
[TestMethod]
public void TestMethod1()
{
if (true == true)
{
Assert.AreEqual(1, 1);
}
}
}
}
Expected behavior:
Suggestion to use fluent assertions instead of Assert is shown when Assert is not on the top level of nesting in a test method.
Actual behavior:
Suggestion to use fluent assertions instead of Assert is not shown when Assert is not on the top level of nesting in a test method.
Versions
- Which version of Fluent Assertions Analyzers are you using? FluentAssertions.Analyzers 0.17.2
- Which .NET runtime and version are you targeting? .NET Core 3.1.