Suggestions to use fluent assertions instead of MSTest Asserts do not work if "using Microsoft.VisualStudio.TestTools.UnitTesting;" is located inside of the namespace.
See original GitHub issueDescription
Newly added functionality enabling easy move from MSTest Asserts to fluent assertions does not work if “using Microsoft.VisualStudio.TestTools.UnitTesting;” is located inside of the namespace.
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()
{
Assert.AreEqual(1, 1);
}
}
}
Expected behavior:
Suggestion to use fluent assertions instead of Assert is shown when “using Microsoft.VisualStudio.TestTools.UnitTesting;” is located inside of the namespace.
Actual behavior:
Suggestion to use fluent assertions instead of Assert is not shown when “using Microsoft.VisualStudio.TestTools.UnitTesting;” is located inside of the namespace.
Versions
- Which version of Fluent Assertions Analyzers are you using? FluentAssertions.Analyzers 0.16.0
- Which .NET runtime and version are you targeting? .NET Core 3.1.
Issue Analytics
- State:
- Created a year ago
- Comments:8 (4 by maintainers)
Top Results From Across the Web
Tips - Fluent Assertions
The examples below show how you might improve your existing assertions to both get more readable assertions and much more informative failure messages....
Read more >Use Assert classes for unit testing - Visual Studio
Learn how to use Assert statements to test the correctness of your code behavior during a unit test of your application code.
Read more >Fluent Assertions Vs MS Test Assertions
Introduction This document talks about how we tackle unit and integration tests using MS Test assertions and Fluent Assertions.
Read more >How do I use Assert to verify that an exception has been ...
How do I use Assert (or other Test class) to verify that an exception has been thrown when using MSTest/Microsoft.VisualStudio.TestTools.
Read more >Introduction to Unit Testing with: MS tests, NUnit and Fluent ...
This article will show you the basic of using MS Unit Test ,NUnit & Fluent Assertions. I'm not intending to cover everything, but...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@robertMSFTE should be working now with version
0.17.2
@robertMSFTE just published version
0.17.1
with fixed package