To make assertions about collections, you should use CollectionAssert
:
CollectionAssert.AreEqual(expected, actual);
List<T>
doesn’t override Equals
, so if Assert.AreEqual
just calls Equals
, it will end up using reference equality.
More Related Contents:
- Unit testing private methods in C#
- Unit Testing: DateTime.Now
- How can we run a test method with multiple parameters in MSTest?
- How do I use Assert to verify that an exception has been thrown?
- How do I ignore the UTF-8 Byte Order Marker in String comparisons?
- How can I write output from a unit test?
- MSTest Equivalent for NUnit’s Parameterized Tests?
- How do I use Assert to verify that an exception has been thrown with MSTest?
- MSTest cannot find the assembly
- Why does TestInitialize get fired for every test in my Visual Studio unit tests?
- How can I get “Copy to Output Directory” to work with Unit Tests?
- Error Message is not clear to me
- Using IoC for Unit Testing
- Interop type cannot be embedded
- Mocking Static Methods
- Mock static property with moq
- How to mock the new HttpClientFactory in .NET Core 2.1 using Moq
- Mock HttpContext for unit testing a .NET core MVC controller?
- How to write to Console.Out during execution of an MSTest test
- Visual Studio designer in x64 doesn’t work
- Moq + Unit Testing – System.Reflection.TargetParameterCountException: Parameter count mismatch
- Assert an Exception using XUnit
- I’m getting the “missing a using directive or assembly reference” and no clue what’s going wrong
- How to test method call order with Moq
- visual studio 2010 conditional references
- Test method is inconclusive: Test wasn’t run. Error?
- Shared AssemblyInfo for uniform versioning across the solution
- Using DI container in unit tests
- Using Moq to override virtual methods in the same class
- Xamarin (Android) Unit Tests in Visual Studio 2017