Creating a NUnit constraint meaning “{collection} does not contain {item}”
Assert.That(schedule.PendingItems, Has.No.Member(item)) Only with NUnit 2.4 / 2.5
Assert.That(schedule.PendingItems, Has.No.Member(item)) Only with NUnit 2.4 / 2.5
If you’re comparing two lists, you should use test using collection constraints. Assert.That(actual, Is.EquivalentTo(expected)); Also, in your classes, you will need to override the Equals method, otherwise like gleng stated, the items in the list are still going to be compared based on reference. Simple override example: public class Example { public int ID { … Read more
Use the fluent interface to create assertions: Assert.That(() => new ApplicationArguments(args), Throws.TypeOf<ArgumentException>() .With.Message.EqualTo(“Invalid ending parameter of the workbook. Please use .xlsx random random”));
You don’t provide enough information to diagnose what is wrong with your project file, but it 3.9.0 of the NUnit Adapter does work with .NET Standard 2.0 and F#. I think that your test project is targeting .NET Standard. It needs to target .NET Core or .NET 4.6.1+. Test projects are treated like executables, they … Read more
From msdn: By default, a Double value contains 15 decimal digits of precision, although a maximum of 17 digits is maintained internally. Let’s assume 15, then. So, we could say that we want the tolerance to be to the same degree. How many precise figures do we have after the decimal point? We need to … Read more
As mentioned in the accepted answer, ReSharper 9 does not support NUnit 3. The solution as stated does work (i.e. update to ReSharper 10), however, for those who do not have this option (e.g. licensing), you can downgrade your version of NUnit by following the below steps: Open Nuget Package Manager Console by going to … Read more
List item speed is same, but MsTest may be a bit slower because it creates folder for test run every time MSBuid and CC.Net is big pain. You can’t run MSTest on computer without VS on it (not 100 sure about 2010, but with 2008 it is so) not sure, sorry yes you can, from … Read more
I’ve found a way that fits my purposes Have one test case, and mark it with the TestCaseSource attribute like so [Test, TestCaseSource(“GetTestCases”)] public void TestFile(string filename) { //do test } Then write the GetTestCases to read all the file names in the directory private static string[] GetTestCases() { return GetAllFilesInCurrentDirectory(); } Then when I … Read more
If all your test fixtures are within the same namespace then you can use the [SetUpFixture] attribute to mark a class as the global setup and teardown. You can then put all your login/logout functionality in there. NUNIT 2.x namespace MyNamespace.Tests { using System; using NUnit.Framework; [SetUpFixture] public class TestsSetupClass { [SetUp] public void GlobalSetup() … Read more