Esempio n. 1
0
        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);
            }
        }
Esempio n. 2
0
        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);
            }
        }
Esempio n. 3
0
        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);
        }
Esempio n. 5
0
        public void TestTextColorPropertyWithNotSupportedTestStatusReturnsColorBlack()
        {
            TestResultForTest result = new TestResultForTest();

            result.ResultState = new ResultState((TestStatus)(-1));

            INUnitTestResult test = new NUnitTestResult(result);

            Assert.AreEqual(Color.Black, test.TextColor);
        }
Esempio n. 6
0
        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);
        }
Esempio n. 7
0
        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));
        }
Esempio n. 8
0
        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);
        }
Esempio n. 9
0
        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);
        }
Esempio n. 10
0
        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);
        }
Esempio n. 11
0
        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);
        }
Esempio n. 12
0
        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);
        }
Esempio n. 13
0
        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);
        }
Esempio n. 14
0
        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);
        }
Esempio n. 15
0
        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);
        }
Esempio n. 16
0
        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);
        }
Esempio n. 17
0
        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);
        }
Esempio n. 18
0
        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);
        }
Esempio n. 20
0
        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);
        }
Esempio n. 21
0
        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);
        }
Esempio n. 22
0
        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);
        }
Esempio n. 23
0
        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);
        }
Esempio n. 24
0
        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);
        }
Esempio n. 25
0
        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);
        }
Esempio n. 26
0
        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);
        }
Esempio n. 27
0
        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);
        }
Esempio n. 28
0
        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);
        }
Esempio n. 29
0
        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);
        }
Esempio n. 30
0
        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);
        }