public void TestHasFailedAssertionsPropertyReturnsIfTestsHasFailedAssertion([Values] bool hasResult, [Values] bool hasAssertions, [Values] AssertionStatus status) { bool expected = hasResult && hasAssertions && status != AssertionStatus.Passed; IList <AssertionResult> assertions = new List <AssertionResult> { new AssertionResult(AssertionStatus.Passed, "message", "trace"), null, new AssertionResult(status, "message", "trace"), new AssertionResult(AssertionStatus.Passed, "message", "trace") }; TestResultForTest resultInstance = new TestResultForTest(); resultInstance.AssertionResults = hasAssertions ? assertions : null; ITestResult result = hasResult ? resultInstance : null; INUnitTestResult test = new NUnitTestResult(result); Assert.AreEqual(expected, test.HasFailedAssertions); if (hasResult && hasAssertions) { CollectionAssert.AreEqual(assertions, test.AssertionResults); } else { CollectionAssert.IsEmpty(test.AssertionResults); } }
public void TestAddToXml([Values] bool hasResult, [Values] bool isParentNull, [Values] bool recursive) { ITestResult resultInstance = new TestSuiteResult(new TestSuite("suite-name")); ITestResult result = hasResult ? resultInstance : null; INUnitTestResult test = new NUnitTestResult(result); TNode parent = isParentNull ? null : new TNode("parent-node"); // Parent node null is not handled by NUnit implementation of ITestResult nor the thin wrapper being tested here if (hasResult && isParentNull) { // ReSharper disable once ExpressionIsAlwaysNull Assert.Throws(Is.TypeOf <NullReferenceException>(), () => test.AddToXml(parent, recursive)); return; } TNode node = test.AddToXml(parent, recursive); if (hasResult) { Assert.IsNotNull(node); } else { Assert.IsNull(node); } }
public void TestConstructorWithTestResult([Values] bool isNull) { ITestResult result = isNull ? null : new TestResultForTest(); INUnitTestResult test = new NUnitTestResult(result); Assert.AreSame(result, test.Result); }
public void FiringTestResultsMonitorTestFinishedCreatesNUnitTestResultWithCorrectNameFromNUnitTestRunnerTestFinishedEvent() { CreateNUnitTestRunner(); StartNUnitTestRunner(); TestResult testResultToFire = new TestResult("abc"); NUnitTestResult resultFromEventHandler = FireTestResult(testResultToFire) as NUnitTestResult; Assert.AreEqual("abc", resultFromEventHandler.Name); }
public void TestTextColorPropertyWithNotSupportedTestStatusReturnsColorBlack() { TestResultForTest result = new TestResultForTest(); result.ResultState = new ResultState((TestStatus)(-1)); INUnitTestResult test = new NUnitTestResult(result); Assert.AreEqual(Color.Black, test.TextColor); }
public void TestTextColorPropertyWithNullResultReturnsColorBlack([Values] bool hasResult) { TestResultForTest resultInstance = new TestResultForTest(); resultInstance.ResultState = null; ITestResult result = hasResult ? resultInstance : null; INUnitTestResult test = new NUnitTestResult(result); Assert.AreEqual(Color.Black, test.TextColor); }
public void TestEqualsWithSameResultReturnsTrue([Values] bool isNull) { TestResultForTest resultInstanceOne = new TestResultForTest(); ITestResult resultOne = isNull ? null : resultInstanceOne; INUnitTestResult testOne = new NUnitTestResult(resultOne); Assert.IsTrue(testOne.Equals(resultOne)); // ReSharper disable once EqualExpressionComparison Assert.IsTrue(testOne.Equals(testOne)); }
public void TestHasStackTracePropertyWithStackTraceReturnsTrue() { const string msg = "This is a test message."; TestResultForTest result = new TestResultForTest(); result.StackTrace = msg; INUnitTestResult test = new NUnitTestResult(result); Assert.AreEqual(msg, test.StackTrace); Assert.IsTrue(test.HasStackTrace); }
public void TestHasMessagePropertyWithNoMessageReturnsFalse([Values] bool hasResult, [Values] bool isNull) { TestResultForTest resultInstance = new TestResultForTest(); resultInstance.Message = isNull ? null : string.Empty; ITestResult result = hasResult ? resultInstance : null; INUnitTestResult test = new NUnitTestResult(result); Assert.AreEqual(string.Empty, test.Message); Assert.IsFalse(test.HasMessage); }
public void TestHasOutputPropertyWithOutputReturnsTrue() { const string msg = "This is a test message."; TestResultForTest result = new TestResultForTest(); result.Output = msg; INUnitTestResult test = new NUnitTestResult(result); Assert.AreEqual(msg, test.Output); Assert.IsTrue(test.HasOutput); }
public void TestHasSkipPropertyWithSkipReturnsTrue() { const int count = 5; TestResultForTest result = new TestResultForTest(); result.SkipCount = count; INUnitTestResult test = new NUnitTestResult(result); Assert.AreEqual(count, test.SkipCount); Assert.IsTrue(test.HasSkip); }
public void TestHasSkipPropertyWithNoSkipReturnsFalse([Values] bool hasResult) { TestResultForTest resultInstance = new TestResultForTest(); resultInstance.SkipCount = 0; ITestResult result = hasResult ? resultInstance : null; INUnitTestResult test = new NUnitTestResult(result); Assert.AreEqual(0, test.SkipCount); Assert.IsFalse(test.HasSkip); }
public void TestHasWarningPropertyWithWarningReturnsTrue() { const int count = 5; TestResultForTest result = new TestResultForTest(); result.WarningCount = count; INUnitTestResult test = new NUnitTestResult(result); Assert.AreEqual(count, test.WarningCount); Assert.IsTrue(test.HasWarning); }
public void TestHasWarningPropertyWithNoWarningReturnsFalse([Values] bool hasResult) { TestResultForTest resultInstance = new TestResultForTest(); resultInstance.InconclusiveCount = 0; ITestResult result = hasResult ? resultInstance : null; INUnitTestResult test = new NUnitTestResult(result); Assert.AreEqual(0, test.WarningCount); Assert.IsFalse(test.HasWarning); }
public void TestHasInconclusivePropertyWithInconclusiveReturnsTrue() { const int count = 5; TestResultForTest result = new TestResultForTest(); result.InconclusiveCount = count; INUnitTestResult test = new NUnitTestResult(result); Assert.AreEqual(count, test.InconclusiveCount); Assert.IsTrue(test.HasInconclusive); }
public void TestResultStateStatusPropertyWithResultNullReturnsDefaultString([Values] bool hasResult) { TestResultForTest resultInstance = new TestResultForTest(); resultInstance.ResultState = null; ITestResult result = hasResult ? resultInstance : null; INUnitTestResult test = new NUnitTestResult(result); Assert.AreEqual(result, test.Result); Assert.AreEqual("Test not executed.", test.ResultStateStatus); }
public void TestResultStateStatusPropertyWithResultReturnsResultStateStatusString() { ResultState state = ResultState.Success; TestResultForTest result = new TestResultForTest(); result.ResultState = state; INUnitTestResult test = new NUnitTestResult(result); Assert.IsNotNull(test.Result); Assert.AreEqual(state.Status.ToString(), test.ResultStateStatus); }
public void TestHasChildrenPropertyReturnsIfTestHasChildren([Values] bool hasResult, [Values] bool hasChildren) { bool expected = hasResult && hasChildren; TestResultForTest resultInstance = new TestResultForTest(); resultInstance.HasChildren = hasChildren; ITestResult result = hasResult ? resultInstance : null; INUnitTestResult test = new NUnitTestResult(result); Assert.AreEqual(expected, test.HasChildren); }
public void Init() { TestResult testResult = new TestResult("MyNamespace.MyTests"); testResult.ResultType = TestResultType.Failure; testResult.Message = "Test failed"; testResult.StackTrace = "Test Error : MyTest.Test\r\n" + "at TestResultTask.Create() in c:\\projects\\SharpDevelop\\TestResultTask.cs:line 45\r\n" + "at MyTest.Test() in c:\\myprojects\\test\\..\\test\\mytest.cs:line 28\r\n" + ""; nunitTestResult = new NUnitTestResult(testResult); }
public void TestResultPropertyCanBeSet([Values] bool isNull) { ITestResult result = !isNull ? null : new TestResultForTest(); ITestResult expected = isNull ? null : new TestResultForTest(); INUnitTestResult test = new NUnitTestResult(result); Assert.AreSame(result, test.Result); test.Result = expected; Assert.AreSame(expected, test.Result); }
public void TestResultStatePropertyReturnsResultState([Values] bool hasResult, [Values] bool hasState) { ResultState state = ResultState.Success; ResultState expected = hasResult && hasState ? state : ResultState.Inconclusive; TestResultForTest resultInstance = new TestResultForTest(); resultInstance.ResultState = hasState ? state : null; ITestResult result = hasResult ? resultInstance : null; INUnitTestResult test = new NUnitTestResult(result); Assert.AreEqual(expected, test.ResultState); }
public void TestFullNamePropertyReturnsResultFullName([Values] bool hasResult, [Values] bool hasName) { const string name = "result-name"; string expected = hasResult && hasName ? name : string.Empty; TestResultForTest resultInstance = new TestResultForTest(); resultInstance.FullName = hasName ? name : null; ITestResult result = hasResult ? resultInstance : null; INUnitTestResult test = new NUnitTestResult(result); Assert.AreEqual(expected, test.FullName); }
public void TestOutputPropertyReturnsResultOutputMessages([Values] bool hasResult, [Values] bool hasOutput) { const string output = "This is a test message."; string expected = hasResult && hasOutput ? output : string.Empty; TestResultForTest resultInstance = new TestResultForTest(); resultInstance.Output = hasOutput ? output : null; ITestResult result = hasResult ? resultInstance : null; INUnitTestResult test = new NUnitTestResult(result); Assert.AreEqual(expected, test.Output); }
public void TestTestPropertyReturnsTest([Values] bool hasResult, [Values] bool hasTest) { ITest testInstance = new TestSuite("suite-name"); ITest expected = hasResult && hasTest ? testInstance : null; TestResultForTest resultInstance = new TestResultForTest(); resultInstance.Test = expected; ITestResult result = hasResult ? resultInstance : null; INUnitTestResult test = new NUnitTestResult(result); Assert.AreSame(expected, test.Test); }
public void TestChildrenPropertyReturnsChildren([Values] bool hasResult, [Values] bool hasChildren) { IEnumerable <ITestResult> children = new List <ITestResult>(); IEnumerable <ITestResult> expected = hasResult && hasChildren ? children : null; TestResultForTest resultInstance = new TestResultForTest(); resultInstance.Children = expected; ITestResult result = hasResult ? resultInstance : null; INUnitTestResult test = new NUnitTestResult(result); Assert.AreSame(expected, test.Children); }
public void TestInconclusiveCountPropertyReturnsInconclusiveCount([Values] bool hasResult) { const int count = 5; int expected = hasResult ? count : 0; TestResultForTest resultInstance = new TestResultForTest(); resultInstance.InconclusiveCount = count; ITestResult result = hasResult ? resultInstance : null; INUnitTestResult test = new NUnitTestResult(result); Assert.AreEqual(expected, test.InconclusiveCount); }
public void TestMessagePropertyReturnsResultExceptionMessage([Values] bool hasResult, [Values] bool hasMsg) { const string msg = "This is a test message."; string expected = hasResult && hasMsg ? msg : string.Empty; TestResultForTest resultInstance = new TestResultForTest(); resultInstance.Message = hasMsg ? msg : null; ITestResult result = hasResult ? resultInstance : null; INUnitTestResult test = new NUnitTestResult(result); Assert.AreEqual(expected, test.Message); }
public void TestEndTimePropertyReturnsTestEndTime([Values] bool hasResult) { DateTime time = DateTime.Now; DateTime expected = hasResult ? time : DateTime.MaxValue; TestResultForTest resultInstance = new TestResultForTest(); resultInstance.EndTime = time; ITestResult result = hasResult ? resultInstance : null; INUnitTestResult test = new NUnitTestResult(result); Assert.AreEqual(expected, test.EndTime); }
public void TestDurationPropertyReturnsTestDuration([Values] bool hasResult) { const double duration = 5.123456; double expected = hasResult ? duration : 0; TestResultForTest resultInstance = new TestResultForTest(); resultInstance.Duration = duration; ITestResult result = hasResult ? resultInstance : null; INUnitTestResult test = new NUnitTestResult(result); Assert.AreEqual(expected, test.Duration); }
public void TestStackTracePropertyReturnsResultExceptionStackTrace([Values] bool hasResult, [Values] bool hasTrace) { const string trace = "This is a test message."; string expected = hasResult && hasTrace ? trace : string.Empty; TestResultForTest resultInstance = new TestResultForTest(); resultInstance.StackTrace = hasTrace ? trace : null; ITestResult result = hasResult ? resultInstance : null; INUnitTestResult test = new NUnitTestResult(result); Assert.AreEqual(expected, test.StackTrace); }