public void Execute_DifferentTestFormats_TestsAreAdded( string testDll, string testNamespace, string testClass, string testFunction) { // Setup: string testName = CreateFullTestName(testNamespace, testClass, testFunction); string line = StringUtils.FormatInvariant("{0} | {1}", testDll, testName); // Create a file with the specified line of text. _filename = FileUtilities.CreateTempFile(); FileUtilities.AppendLineToFile(_filename, line); var plugin = new NUnitReaderPlugin(_filename); // Execute: Assert.IsTrue(plugin.Execute(), "{0} should return true!", EXECUTE_FUNC); // Verify: Assert.AreEqual(1, plugin.Tests.Count, "There should be 1 test in the file!"); var test = plugin.Tests[0]; // These should have the values we set. Assert.AreEqual(testNamespace, test.TestNamespace, "Test.TestNamespace doesn't have the expected value!"); Assert.AreEqual(testClass, test.TestClass, "Test.TestClass doesn't have the expected value!"); Assert.AreEqual(testFunction, test.TestFunction, "Test.TestFunction doesn't have the expected value!"); Assert.AreEqual(testName, test.TestName, "Test.TestName doesn't have the expected value!"); var nunitTest = test as NUnitTest; Assert.AreEqual(testDll, nunitTest.DllPath, "NUnitTest.DllPath doesn't have the expected value!"); // These shouldn't have any values in them. Assert.AreEqual(0, test.ExtendedProperties.Count, "Test.ExtendedProperties should be empty!"); Assert.AreEqual(0, test.TestRuns.Count, "Test.TestRuns should be empty!"); }
public static void Execute_NonExistentFile_FileNotFoundException() { // Setup: var plugin = new NUnitReaderPlugin("ThisFileShouldNotExist"); // Execute & Verify: Assert.Throws <FileNotFoundException>(() => plugin.Execute(), "{0} should throw a FileNotFoundException if the test file doesn't exist!", EXECUTE_FUNC); }
public void Execute_EmptyFile_NoTests() { // Setup: // Create an empty file. _filename = FileUtilities.CreateTempFile(); var plugin = new NUnitReaderPlugin(_filename); // Execute: Assert.IsTrue(plugin.Execute(), "{0} should return true!", EXECUTE_FUNC); // Verify: Assert.AreEqual(0, plugin.Tests.Count, "There should be no tests in a blank file!"); }
public void Execute_ValidData_ExpectedNumberOfTests(int expectedNumberOfTests, string line) { // Setup: // Create a file with the specified line of text. _filename = FileUtilities.CreateTempFile(); FileUtilities.AppendLineToFile(_filename, line); var plugin = new NUnitReaderPlugin(_filename); // Execute: Assert.IsTrue(plugin.Execute(), "{0} should return true!", EXECUTE_FUNC); // Verify: Assert.AreEqual(expectedNumberOfTests, plugin.Tests.Count, "There should be {0} tests in the file!", expectedNumberOfTests); }
public void Execute_WrongNumberOfPartsInFile_InvalidDataException(string line) { // Setup: // Create a file with the specified line of text. _filename = FileUtilities.CreateTempFile(); FileUtilities.AppendLineToFile(_filename, line); var plugin = new NUnitReaderPlugin(_filename); // Execute: Assert.Throws <InvalidDataException>(() => plugin.Execute(), "{0} should throw a InvalidDataException if there aren't exactly 2 parts in the file!", EXECUTE_FUNC); // Verify: Assert.AreEqual(0, plugin.Tests.Count, "There should be no tests in a blank file!"); }