How to compare Lists in Unit Testing

How can this test fail? [TestMethod] public void Get_Code() { var expected = new List<int>(); expected.AddRange(new [] { 100, 400, 200, 900, 2300, 1900 }); var actual = new List<int>(); actual.AddRange(new [] { 100, 400, 200, 900, 2300, 1900 }); Assert.AreEqual(expected, actual); // Assert.AreSame(expected, actual) fails // Assert.IsTrue(expected.Equals(actual)) fails } 7 Answers 7

Your project does not reference “.NETFramework,Version=v4.6.2” framework. Add a reference to “.NETFramework,Version=v4.6.2” in the “TargetFrameworks”

I can’t run my unit tests. I have the next error: Your project does not reference “.NETFramework,Version=v4.6.2” framework. Add a reference to “.NETFramework,Version=v4.6.2” in the “TargetFrameworks” property of your project file and then re-run NuGet restore. In app.config: <startup> <supportedRuntime version=”v4.0″ sku=”.NETFramework,Version=v4.6.2″/> </startup> In Project > Properties > Application > TargetFramework (.NET Framework 4.6.2) How … Read more

NUnit vs. MbUnit vs. MSTest vs. xUnit.net [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for … Read more

Entity Framework Provider type could not be loaded?

I am trying to run my tests on TeamCity which is currently installed on my machine. System.InvalidOperationException: The Entity Framework provider type ‘System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089′ for the ‘System.Data.SqlClient‘ ADO.NET provider could not be loaded. Make sure the provider assembly is available to the running application. See http://go.microsoft.com/fwlink/?LinkId=260882 for more information.. I have no … Read more

How do I use Assert to verify that an exception has been thrown?

How do I use Assert (or other Test class) to verify that an exception has been thrown? 24 s 24 For “Visual Studio Team Test” it appears you apply the ExpectedException attribute to the test’s method. Sample from the documentation here: A Unit Testing Walkthrough with Visual Studio Team Test [TestMethod] [ExpectedException(typeof(ArgumentException), “A userId of … Read more