コード例 #1
0
        public void ResultNotSet()
        {
            TestSuiteTreeNode node = new TestSuiteTreeNode(testCaseInfo);

            Assert.AreEqual(TestSuiteTreeNode.InitIndex, node.ImageIndex);
            Assert.AreEqual(TestSuiteTreeNode.InitIndex, node.SelectedImageIndex);
        }
コード例 #2
0
        public void WhenResultIsNotSet_IndexReflectsRunState(string testName, int expectedIndex)
        {
            Test test = TestFinder.Find(testName, testFixture, false);
            TestSuiteTreeNode node = new TestSuiteTreeNode(new TestInfo(test));

            Assert.AreEqual(expectedIndex, node.ImageIndex);
            Assert.AreEqual(expectedIndex, node.SelectedImageIndex);
        }
コード例 #3
0
            private void FindCheckedNodes(TestSuiteTreeNode node, bool topLevel)
            {
                if (node.Checked)
                {
                    checkedTests.Add(new CheckedTestInfo(node.Test, topLevel));
                    topLevel = false;
                }

                FindCheckedNodes(node.Nodes, topLevel);
            }
コード例 #4
0
        public void SetResult_Success()
        {
            TestSuiteTreeNode node   = new TestSuiteTreeNode(testCaseInfo);
            TestResult        result = new TestResult(testCaseInfo);

            result.Success();
            node.Result = result;
            Assert.AreEqual(TestSuiteTreeNode.SuccessIndex, node.ImageIndex);
            Assert.AreEqual(TestSuiteTreeNode.SuccessIndex, node.SelectedImageIndex);
            Assert.AreEqual("Success", node.StatusText);
        }
コード例 #5
0
        public void WhenResultIsSet_IndexReflectsResultState(ResultState resultState, int expectedIndex)
        {
            TestSuiteTreeNode node   = new TestSuiteTreeNode(new TestInfo(testCase));
            TestResult        result = new TestResult(testCase);

            result.SetResult(resultState, null, null);
            node.Result = result;
            Assert.AreEqual(expectedIndex, node.ImageIndex);
            Assert.AreEqual(expectedIndex, node.SelectedImageIndex);
            Assert.AreEqual(resultState.ToString(), node.StatusText);
        }
コード例 #6
0
        public void SetResult_Failure()
        {
            TestSuiteTreeNode node   = new TestSuiteTreeNode(testCaseInfo);
            TestResult        result = new TestResult(testCaseInfo);

            result.Failure("message", "stacktrace");
            node.Result = result;
            Assert.AreEqual(TestSuiteTreeNode.FailureIndex, node.ImageIndex);
            Assert.AreEqual(TestSuiteTreeNode.FailureIndex, node.SelectedImageIndex);
            Assert.AreEqual("Failure", node.StatusText);
        }
コード例 #7
0
        public void SetResult_Skipped()
        {
            TestSuiteTreeNode node   = new TestSuiteTreeNode(testCaseInfo);
            TestCaseResult    result = new TestCaseResult(testCaseInfo);

            result.RunState = RunState.Skipped;
            node.Result     = result;
            Assert.AreEqual(TestSuiteTreeNode.SkippedIndex, node.ImageIndex);
            Assert.AreEqual(TestSuiteTreeNode.SkippedIndex, node.SelectedImageIndex);
            Assert.AreEqual("Skipped", node.StatusText);
        }
コード例 #8
0
        public void SetResult_Init()
        {
            TestSuiteTreeNode node   = new TestSuiteTreeNode(testCaseInfo);
            TestCaseResult    result = new TestCaseResult(testCaseInfo);

            node.Result = result;
            Assert.AreEqual("NUnit.Tests.Assemblies.MockTestFixture.MockTest1", node.Result.Name);
            Assert.AreEqual(TestSuiteTreeNode.InitIndex, node.ImageIndex);
            Assert.AreEqual(TestSuiteTreeNode.InitIndex, node.SelectedImageIndex);
            Assert.AreEqual("Runnable", node.StatusText);
        }
コード例 #9
0
        public void WhenResultIsSet_IndexReflectsResultState(ResultState resultState, int expectedIndex)
        {
            TestSuiteTreeNode node = new TestSuiteTreeNode(new TestInfo(testCase));
            TestResult result = new TestResult(testCase);

            result.SetResult(resultState, null, null);
            node.Result = result;
            Assert.AreEqual(expectedIndex, node.ImageIndex);
            Assert.AreEqual(expectedIndex, node.SelectedImageIndex);
            Assert.AreEqual(resultState.ToString(), node.StatusText);
        }
コード例 #10
0
        public void ProcessTreeNodes(TestSuiteTreeNode node)
        {
            if (IsInteresting(node))
            {
                this.Nodes.Add(new VisualTreeNode(node));
            }

            foreach (TestSuiteTreeNode childNode in node.Nodes)
            {
                ProcessTreeNodes(childNode);
            }
        }
コード例 #11
0
        public void SetResult_Inconclusive()
        {
            TestSuiteTreeNode node = new TestSuiteTreeNode(testCaseInfo);
            TestResult result = new TestResult(testCaseInfo);

            result.SetResult(ResultState.Inconclusive, null, null);
            node.Result = result;
            Assert.AreEqual("MockTest1", node.Result.Name);
            Assert.AreEqual(TestSuiteTreeNode.InconclusiveIndex, node.ImageIndex);
            Assert.AreEqual(TestSuiteTreeNode.InconclusiveIndex, node.SelectedImageIndex);
            Assert.AreEqual(result.ResultState.ToString(), node.StatusText);
        }
コード例 #12
0
        public void SetResult_Ignore()
        {
            TestSuiteTreeNode node   = new TestSuiteTreeNode(testCaseInfo);
            TestResult        result = new TestResult(testCaseInfo);

            result.Ignore("reason");
            node.Result = result;
            Assert.AreEqual("MockTest1", node.Result.Name);
            Assert.AreEqual(TestSuiteTreeNode.IgnoredIndex, node.ImageIndex);
            Assert.AreEqual(TestSuiteTreeNode.IgnoredIndex, node.SelectedImageIndex);
            Assert.AreEqual("Ignored", node.StatusText);
        }
コード例 #13
0
        public void SetResult_Inconclusive()
        {
            TestSuiteTreeNode node   = new TestSuiteTreeNode(testCaseInfo);
            TestResult        result = new TestResult(testCaseInfo);

            result.SetResult(ResultState.Inconclusive, null, null);
            node.Result = result;
            Assert.AreEqual("MockTest1", node.Result.Name);
            Assert.AreEqual(TestSuiteTreeNode.InconclusiveIndex, node.ImageIndex);
            Assert.AreEqual(TestSuiteTreeNode.InconclusiveIndex, node.SelectedImageIndex);
            Assert.AreEqual(result.ResultState.ToString(), node.StatusText);
        }
コード例 #14
0
        public void WhenResultIsCleared_IndexReflectsRunState(string runState, int expectedIndex)
        {
            var result             = new ResultNode($"<test-case id='123' name='SomeTest' fullname='A.B.C.SomeTest' runstate='{runState}' result='Failed'/>");
            TestSuiteTreeNode node = new TestSuiteTreeNode(result);

            Assert.AreEqual(TestSuiteTreeNode.FailureIndex, node.ImageIndex);
            Assert.AreEqual(TestSuiteTreeNode.FailureIndex, node.SelectedImageIndex);

            node.ClearResults();
            Assert.AreEqual(null, node.Result);
            Assert.AreEqual(expectedIndex, node.ImageIndex);
            Assert.AreEqual(expectedIndex, node.SelectedImageIndex);
        }
コード例 #15
0
        public void WhenTestSuiteCompletes_ResultIsPosted()
        {
            var suite    = new TestNode("<test-suite id='100' name='DUMMY'/>");
            var treeNode = new TestSuiteTreeNode(suite);

            _presenter.TreeMap["100"] = treeNode;

            var result = new ResultNode("<test-suite id='100' name='DUMMY' result='Passed'/>");

            _model.Events.SuiteFinished += Raise.Event <TestResultEventHandler>(new TestResultEventArgs(result));

            Assert.That(treeNode.Result, Is.EqualTo(result));
        }
コード例 #16
0
        public void SetTestResult()
        {
            TestSuite  fixture = (TestSuite)findTest("MockTestFixture", suite);
            TestResult result  = new TestResult(new TestInfo(fixture));

            treeView.SetTestResult(result);

            TestSuiteTreeNode fixtureNode = FixtureNode(treeView);

            Assert.IsNotNull(fixtureNode.Result, "Result not set");
            Assert.AreEqual(fixture.TestName.Name, fixtureNode.Result.Name);
            Assert.AreEqual(fixtureNode.Test.TestName.FullName, fixtureNode.Result.Test.TestName.FullName);
        }
コード例 #17
0
        public void ConstructFromTestInfo()
        {
            TestSuiteTreeNode node;

            node = new TestSuiteTreeNode(suiteInfo);
            Assert.AreEqual("MyTestSuite", node.Text);

            node = new TestSuiteTreeNode(fixtureInfo);
            Assert.AreEqual("MockTestFixture", node.Text);

            node = new TestSuiteTreeNode(testCaseInfo);
            Assert.AreEqual("MockTest1", node.Text);
        }
コード例 #18
0
        public void WhenResultIsSet_IndexReflectsResultState(string outcome, int expectedIndex)
        {
            int    colon      = outcome.IndexOf(':');
            string resultPart = colon >= 0
                ? $"result='{outcome.Substring(0, colon)}' label='{outcome.Substring(colon + 1)}'"
                : $"result='{outcome}'";

            var result             = new ResultNode($"<test-case id='123' name='SomeTest' fullname='A.B.C.SomeTest' runstate='Runnable' {resultPart}/>");
            TestSuiteTreeNode node = new TestSuiteTreeNode(result);

            Assert.AreEqual(expectedIndex, node.ImageIndex);
            Assert.AreEqual(expectedIndex, node.SelectedImageIndex);
            Assert.AreEqual(outcome, node.StatusText);
        }
コード例 #19
0
 public override void Visit(TestSuiteTreeNode node)
 {
     if (!node.Test.IsSuite &&
         node.HasResult &&
         node.Result.Outcome.Status == TestStatus.Failed)
     {
         node.Checked = true;
         node.EnsureVisible();
     }
     else
     {
         node.Checked = false;
     }
 }
コード例 #20
0
        private void CheckThatNodeMatchesTest(TestSuiteTreeNode node, Test test, string msg)
        {
            Assert.AreEqual(test.TestName, node.Test.TestName);

            if (test.IsSuite)
            {
                Assert.AreEqual(test.Tests.Count, node.Nodes.Count, "{0}: Incorrect count for {1}", msg, test.TestName.FullName);

                for (int index = 0; index < test.Tests.Count; index++)
                {
                    CheckThatNodeMatchesTest((TestSuiteTreeNode)node.Nodes[index], (Test)test.Tests[index], msg);
                }
            }
        }
コード例 #21
0
        public void ClearResult()
        {
            TestCaseResult result = new TestCaseResult( testCaseInfo );
            result.Failure("message", "stacktrace");

            TestSuiteTreeNode node = new TestSuiteTreeNode( result );
            Assert.AreEqual( TestSuiteTreeNode.FailureIndex, node.ImageIndex );
            Assert.AreEqual( TestSuiteTreeNode.FailureIndex, node.SelectedImageIndex );

            node.ClearResult();
            Assert.AreEqual( null, node.Result );
            Assert.AreEqual( TestSuiteTreeNode.InitIndex, node.ImageIndex );
            Assert.AreEqual( TestSuiteTreeNode.InitIndex, node.SelectedImageIndex );
        }
コード例 #22
0
        private void CheckTreeMap(TestSuiteTreeView treeView, Test test, string msg)
        {
            TestSuiteTreeNode node = treeView[test.TestName.UniqueName];

            Assert.IsNotNull(node, "{0}: {1} not in map", msg, test.TestName.UniqueName);
            Assert.AreEqual(test.TestName, treeView[test.TestName.UniqueName].Test.TestName, msg);

            if (test.IsSuite)
            {
                foreach (Test child in test.Tests)
                {
                    CheckTreeMap(treeView, child, msg);
                }
            }
        }
コード例 #23
0
        public void UpdateTest()
        {
            TestSuiteTreeNode node;

            node = new TestSuiteTreeNode(suiteInfo);
            UITestNode suiteInfo2 = new UITestNode(new TestSuite("MyTestSuite"));

            node.UpdateTest(suiteInfo2);
            Assert.AreEqual("MyTestSuite", node.Test.FullName);
            Assert.AreEqual(0, node.Test.CountTestCases());

            node.UpdateTest(suiteInfo);
            Assert.AreEqual("MyTestSuite", node.Test.FullName);
            Assert.AreEqual(MockTestFixture.Tests, node.Test.CountTestCases());
        }
コード例 #24
0
        public void ConstructFromTestInfo()
        {
            TestSuiteTreeNode node;

            node = new TestSuiteTreeNode( suiteInfo );
            Assert.AreEqual( "MyTestSuite", node.Text );
            Assert.AreEqual( "Test Suite", node.TestType );

            node = new TestSuiteTreeNode( fixtureInfo );
            Assert.AreEqual( "MockTestFixture", node.Text );
            Assert.AreEqual( "Test Fixture", node.TestType );

            node = new TestSuiteTreeNode( testCaseInfo );
            Assert.AreEqual( "MockTest1", node.Text );
            Assert.AreEqual( "Test Case", node.TestType );
        }
コード例 #25
0
        public void SetTestResult()
        {
            TestSuiteTreeView treeView = new TestSuiteTreeView();

            treeView.Load(suite);

            TestSuiteResult result = new TestSuiteResult(fixture, "My test result");

            treeView.SetTestResult(result);

            TestSuiteTreeNode fixtureNode = FixtureNode(treeView);

            Assert.IsNotNull(fixtureNode.Result, "Result not set");
            Assert.AreEqual("My test result", fixtureNode.Result.Name);
            Assert.AreEqual(fixtureNode.Test.FullName, fixtureNode.Result.Test.FullName);
        }
コード例 #26
0
        public void ClearResult()
        {
            TestResult result = new TestResult(testCaseInfo);

            result.Failure("message", "stacktrace");

            TestSuiteTreeNode node = new TestSuiteTreeNode(result);

            Assert.AreEqual(TestSuiteTreeNode.FailureIndex, node.ImageIndex);
            Assert.AreEqual(TestSuiteTreeNode.FailureIndex, node.SelectedImageIndex);

            node.ClearResults();
            Assert.AreEqual(null, node.Result);
            Assert.AreEqual(TestSuiteTreeNode.InitIndex, node.ImageIndex);
            Assert.AreEqual(TestSuiteTreeNode.InitIndex, node.SelectedImageIndex);
        }
コード例 #27
0
        public void WhenResultIsCleared_IndexReflectsRunState(string testName, int expectedIndex)
        {
            Test       test   = TestFinder.Find(testName, testFixture, false);
            TestResult result = new TestResult(test);

            result.Failure("message", "stacktrace");

            TestSuiteTreeNode node = new TestSuiteTreeNode(result);

            Assert.AreEqual(TestSuiteTreeNode.FailureIndex, node.ImageIndex);
            Assert.AreEqual(TestSuiteTreeNode.FailureIndex, node.SelectedImageIndex);

            node.ClearResults();
            Assert.AreEqual(null, node.Result);
            Assert.AreEqual(expectedIndex, node.ImageIndex);
            Assert.AreEqual(expectedIndex, node.SelectedImageIndex);
        }
コード例 #28
0
        private void InitializeContextMenu()
        {
            _view.ShowCheckBoxes.Checked = _view.CheckBoxes;

            TestSuiteTreeNode targetNode = _view.ContextNode ?? (TestSuiteTreeNode)_view.Tree.SelectedNode;

            if (targetNode != null)
            {
                TestNode    test    = targetNode.Test;
                TestPackage package = targetNode.TestPackage;

                //_view.RunCommand.DefaultItem = _view.RunCommand.Enabled && targetNode.Included &&
                //    (test.RunState == RunState.Runnable || test.RunState == RunState.Explicit);

                TestSuiteTreeNode theoryNode = targetNode.GetTheoryNode();
                _view.ShowFailedAssumptions.Visible = _view.ShowFailedAssumptions.Enabled = theoryNode != null;
                _view.ShowFailedAssumptions.Checked = theoryNode?.ShowFailedAssumptions ?? false;

                bool showProjectMenu = package != null && test.IsProject;

                _view.ProjectMenu.Visible         = _view.ProjectMenu.Enabled = showProjectMenu;
                _view.ActiveConfiguration.Visible = _view.ActiveConfiguration.Enabled = showProjectMenu;
                _view.EditProject.Visible         = _view.EditProject.Enabled = showProjectMenu && Path.GetExtension(package.FullName) == ".nunit";

                if (showProjectMenu)
                {
                    string   activeConfig = package.GetActiveConfig();
                    string[] configNames  = package.GetConfigNames();

                    if (configNames.Length > 0)
                    {
                        _view.ActiveConfiguration.MenuItems.Clear();
                        foreach (string config in configNames)
                        {
                            var configEntry = new ToolStripMenuItem(config);
                            configEntry.Checked = config == activeConfig;
                            configEntry.Click  += (sender, e) => _model.ReloadPackage(package, ((ToolStripMenuItem)sender).Text);
                            _view.ActiveConfiguration.MenuItems.Add(configEntry);
                        }

                        _view.ActiveConfiguration.Visible = _view.ActiveConfiguration.Enabled = true;
                    }
                }
            }
        }
コード例 #29
0
        private void CheckThatNodeMatchesTest(TestSuiteTreeNode node, Test test, string msg)
        {
            Assert.AreEqual(test.TestName, node.Test.TestName, "{0}: Names do not match for {1}", msg, test.TestName.FullName);

            if (test.IsSuite)
            {
                //if ( test.TestName.FullName == "NUnit.Tests.Assemblies.MockTestFixture" )
                //    foreach( TestSuiteTreeNode n in node.Nodes )
                //        Console.WriteLine( n.Test.TestName );

                Assert.AreEqual(test.Tests.Count, node.Nodes.Count, "{0}: Incorrect count for {1}", msg, test.TestName.FullName);

                for (int index = 0; index < test.Tests.Count; index++)
                {
                    CheckThatNodeMatchesTest((TestSuiteTreeNode)node.Nodes[index], (Test)test.Tests[index], msg);
                }
            }
        }
コード例 #30
0
        /// <summary>
        /// Add the result of a test to the tree
        /// </summary>
        /// <param name="result">The result of a test</param>
        private void SetTestResult(ResultNode result)
        {
            if (_treeMap.ContainsKey(result.Id))
            {
                TestSuiteTreeNode node = (TestSuiteTreeNode)_treeMap[result.Id];

                node.Result = result;

                if (result.Type == "Theory")
                {
                    node.RepopulateTheoryNode();
                }
            }
            else
            {
                Debug.WriteLine("Test not found in tree: " + result.FullName);
            }
        }
コード例 #31
0
        public void Restore(TestSuiteTreeView treeView)
        {
            treeView.CheckBoxes = ShowCheckBoxes;

            foreach (VisualTreeNode visualNode in Nodes)
            {
                TestSuiteTreeNode treeNode = treeView[visualNode.Id];
                if (treeNode != null)
                {
                    if (treeNode.IsExpanded != visualNode.Expanded)
                    {
                        treeNode.Toggle();
                    }

                    treeNode.Checked = visualNode.Checked;
                }
            }

            if (this.SelectedNode != null)
            {
                TestSuiteTreeNode treeNode = treeView[SelectedNode];
                if (treeNode != null)
                {
                    treeView.SelectedNode = treeNode;
                }
            }

            if (TopNode != null)
            {
                TestSuiteTreeNode treeNode = treeView[TopNode];
                if (treeNode != null)
                {
                    treeView.TopNode = treeNode;
                }
            }

            if (SelectedCategories != null)
            {
                treeView.Model.SelectCategories(SelectedCategories, ExcludeCategories);
            }

            treeView.Select();
        }
コード例 #32
0
        public void BuildFromResult()
        {
            TestResult result = suite.Run(new NullListener(), TestFilter.Empty);

            treeView.Load(result);
            Assert.AreEqual(MockAssembly.Nodes - MockAssembly.Explicit - MockAssembly.ExplicitFixtures,
                            treeView.GetNodeCount(true));

            TestSuiteTreeNode node = treeView.Nodes[0] as TestSuiteTreeNode;

            Assert.AreEqual(testsDll, node.Text);
            Assert.IsNotNull(node.Result, "No Result on top-level Node");

            node = node.Nodes[0].Nodes[0] as TestSuiteTreeNode;
            Assert.AreEqual("Tests", node.Text);
            Assert.IsNotNull(node.Result, "No Result on TestSuite");

            foreach (TestSuiteTreeNode child in node.Nodes)
            {
                if (child.Text == "Assemblies")
                {
                    node = child.Nodes[0] as TestSuiteTreeNode;
                    Assert.AreEqual("MockTestFixture", node.Text);
                    Assert.IsNotNull(node.Result, "No Result on TestFixture");
                    Assert.AreEqual(true, node.Result.Executed, "MockTestFixture: Executed");

                    TestSuiteTreeNode test1 = node.Nodes[2] as TestSuiteTreeNode;
                    Assert.AreEqual("MockTest1", test1.Text);
                    Assert.IsNotNull(test1.Result, "No Result on TestCase");
                    Assert.AreEqual(true, test1.Result.Executed, "MockTest1: Executed");
                    Assert.AreEqual(false, test1.Result.IsFailure, "MockTest1: IsFailure");
                    Assert.AreEqual(TestSuiteTreeNode.SuccessIndex, test1.ImageIndex);

                    TestSuiteTreeNode test4 = node.Nodes[5] as TestSuiteTreeNode;
                    Assert.AreEqual(false, test4.Result.Executed, "MockTest4: Executed");
                    Assert.AreEqual(TestSuiteTreeNode.IgnoredIndex, test4.ImageIndex);
                    return;
                }
            }

            Assert.Fail("Cannot locate NUnit.Tests.Assemblies node");
        }
コード例 #33
0
        public void BuildFromResult()
        {
            TestSuiteTreeView treeView = new TestSuiteTreeView();
            TestResult        result   = suite.Run(new NullListener());

            treeView.Load(result);
            Assert.AreEqual(MockAssembly.Nodes, treeView.GetNodeCount(true));

            TestSuiteTreeNode node = treeView.Nodes[0] as TestSuiteTreeNode;

            Assert.AreEqual("mock-assembly.dll", node.Text);
            Assert.IsNotNull(node.Result, "No Result on top-level Node");

            node = node.Nodes[0].Nodes[0] as TestSuiteTreeNode;
            Assert.AreEqual("Tests", node.Text);
            Assert.IsNotNull(node.Result, "No Result on TestSuite");

            foreach (TestSuiteTreeNode child in node.Nodes)
            {
                if (child.Text == "Assemblies")
                {
                    node = child.Nodes[0] as TestSuiteTreeNode;
                    Assert.AreEqual("MockTestFixture", node.Text);
                    Assert.IsNotNull(node.Result, "No Result on TestFixture");
                    Assert.IsTrue(node.Result.Executed, "MockTestFixture: Executed=false");

                    TestSuiteTreeNode test1 = node.Nodes[1] as TestSuiteTreeNode;
                    Assert.AreEqual("MockTest1", test1.Text);
                    Assert.IsNotNull(test1.Result, "No Result on TestCase");
                    Assert.IsTrue(test1.Result.Executed, "MockTest1: Executed=false");
                    Assert.IsTrue(test1.Result.IsSuccess, "MockTest1: IsSuccess=false");
                    Assert.AreEqual(TestSuiteTreeNode.SuccessIndex, test1.ImageIndex);

                    TestSuiteTreeNode test4 = node.Nodes[4] as TestSuiteTreeNode;
                    Assert.IsFalse(test4.Result.Executed, "MockTest4: Executed=true");
                    Assert.AreEqual(TestSuiteTreeNode.NotRunIndex, test4.ImageIndex);
                    return;
                }
            }

            Assert.Fail("Cannot locate NUnit.Tests.Assemblies node");
        }
コード例 #34
0
        public void SetResult()
        {
            TestSuiteTreeNode node   = new TestSuiteTreeNode(testCaseInfo);
            TestCaseResult    result = new TestCaseResult(testCase);

            node.SetResult(result);
            Assert.AreEqual("NUnit.Tests.Assemblies.MockTestFixture.MockTest1", node.Result.Name);
            Assert.AreEqual(TestSuiteTreeNode.NotRunIndex, node.ImageIndex);
            Assert.AreEqual(TestSuiteTreeNode.NotRunIndex, node.SelectedImageIndex);

            result.Success();
            node.SetResult(result);
            Assert.AreEqual(TestSuiteTreeNode.SuccessIndex, node.ImageIndex);
            Assert.AreEqual(TestSuiteTreeNode.SuccessIndex, node.SelectedImageIndex);

            result.Failure("message", "stacktrace");
            node.SetResult(result);
            Assert.AreEqual(TestSuiteTreeNode.FailureIndex, node.ImageIndex);
            Assert.AreEqual(TestSuiteTreeNode.FailureIndex, node.SelectedImageIndex);
        }
コード例 #35
0
        private void InitializeContextMenu()
        {
            _view.ShowCheckBoxes.Checked = _view.CheckBoxes;

            TestSuiteTreeNode targetNode = _view.ContextNode ?? (TestSuiteTreeNode)_view.Tree.SelectedNode;

            if (targetNode != null)
            {
                TestNode test = targetNode.Test;

                _view.RunCommand.DefaultItem = _view.RunCommand.Enabled && targetNode.Included &&
                                               (test.RunState == RunState.Runnable || test.RunState == RunState.Explicit);

                TestSuiteTreeNode theoryNode = targetNode.GetTheoryNode();
                _view.ShowFailedAssumptions.Visible = _view.ShowFailedAssumptions.Enabled = theoryNode != null;
                _view.ShowFailedAssumptions.Checked = theoryNode?.ShowFailedAssumptions ?? false;

                _view.ActiveConfiguration.Visible = _view.ActiveConfiguration.Enabled = false;
                if (test.IsProject)
                {
                    TestPackage package      = _model.GetPackageForTest(test.Id);
                    string      activeConfig = _model.GetActiveConfig(package);
                    var         configNames  = _model.GetConfigNames(package);

                    if (configNames.Count > 0)
                    {
                        _view.ActiveConfiguration.MenuItems.Clear();
                        foreach (string config in configNames)
                        {
                            var configEntry = new MenuItem(config);
                            configEntry.Checked = config == activeConfig;
                            configEntry.Click  += (sender, e) => _model.ReloadPackage(package, ((MenuItem)sender).Text);
                            _view.ActiveConfiguration.MenuItems.Add(configEntry);
                        }

                        _view.ActiveConfiguration.Visible = _view.ActiveConfiguration.Enabled = true;
                    }
                }
            }
        }
コード例 #36
0
        public void ClearResults()
        {
            TestCaseResult testCaseResult = new TestCaseResult( testCaseInfo );
            testCaseResult.Success();
            TestSuiteResult testSuiteResult = new TestSuiteResult( fixtureInfo, "MockTestFixture" );
            testSuiteResult.AddResult( testCaseResult );
            testSuiteResult.RunState = RunState.Executed;

            TestSuiteTreeNode node1 = new TestSuiteTreeNode( testSuiteResult );
            TestSuiteTreeNode node2 = new TestSuiteTreeNode( testCaseResult );
            node1.Nodes.Add( node2 );

            Assert.AreEqual( TestSuiteTreeNode.SuccessIndex, node1.ImageIndex );
            Assert.AreEqual( TestSuiteTreeNode.SuccessIndex, node1.SelectedImageIndex );
            Assert.AreEqual( TestSuiteTreeNode.SuccessIndex, node2.ImageIndex );
            Assert.AreEqual( TestSuiteTreeNode.SuccessIndex, node2.SelectedImageIndex );

            node1.ClearResults();

            Assert.AreEqual( TestSuiteTreeNode.InitIndex, node1.ImageIndex );
            Assert.AreEqual( TestSuiteTreeNode.InitIndex, node1.SelectedImageIndex );
            Assert.AreEqual( TestSuiteTreeNode.InitIndex, node2.ImageIndex );
            Assert.AreEqual( TestSuiteTreeNode.InitIndex, node2.SelectedImageIndex );
        }
コード例 #37
0
		private void CheckThatNodeMatchesTest( TestSuiteTreeNode node, Test test, string msg )
		{
			Assert.AreEqual( test.TestName, node.Test.TestName );

			if ( test.IsSuite )
			{
				Assert.AreEqual( test.Tests.Count, node.Nodes.Count, "{0}: Incorrect count for {1}", msg, test.TestName.FullName );

				for( int index = 0; index < test.Tests.Count; index++ )
				{
					CheckThatNodeMatchesTest( (TestSuiteTreeNode)node.Nodes[index], (Test)test.Tests[index], msg );
				}
			}
		}
コード例 #38
0
        public void SetResult_Success()
        {
            TestSuiteTreeNode node = new TestSuiteTreeNode( testCaseInfo );
            TestCaseResult result = new TestCaseResult( testCaseInfo );

            result.Success();
            node.Result = result;
            Assert.AreEqual( TestSuiteTreeNode.SuccessIndex, node.ImageIndex );
            Assert.AreEqual( TestSuiteTreeNode.SuccessIndex, node.SelectedImageIndex );
            Assert.AreEqual( "Success", node.StatusText );
        }
コード例 #39
0
        public void SetResult_Skipped()
        {
            TestSuiteTreeNode node = new TestSuiteTreeNode( testCaseInfo );
            TestCaseResult result = new TestCaseResult( testCaseInfo );

            result.RunState = RunState.Skipped;
            node.Result = result;
            Assert.AreEqual( TestSuiteTreeNode.SkippedIndex, node.ImageIndex );
            Assert.AreEqual( TestSuiteTreeNode.SkippedIndex, node.SelectedImageIndex );
            Assert.AreEqual( "Skipped", node.StatusText );
        }
コード例 #40
0
        public void SetResult_Init()
        {
            TestSuiteTreeNode node = new TestSuiteTreeNode( testCaseInfo );
            TestCaseResult result = new TestCaseResult( testCaseInfo );

            node.Result = result;
            Assert.AreEqual( "NUnit.Tests.Assemblies.MockTestFixture.MockTest1", node.Result.Name );
            Assert.AreEqual( TestSuiteTreeNode.InitIndex, node.ImageIndex );
            Assert.AreEqual( TestSuiteTreeNode.InitIndex, node.SelectedImageIndex );
            Assert.AreEqual( "Runnable", node.StatusText );
        }
コード例 #41
0
        public void DisplayProperties(TestSuiteTreeNode node)
        {
            if (node == null)
            {
                throw new ArgumentNullException(nameof(node));
            }

            _treeNode   = node;
            _testNode   = node.Test;
            _resultNode = node.Result;

            SetTitleBarText();

            testResult.Text = node.StatusText;
            testResult.Font = new Font(this.Font, FontStyle.Bold);
            if (node.TestType == "Project" || node.TestType == "Assembly")
            {
                testName.Text = Path.GetFileName(_testNode.Name);
            }
            else
            {
                testName.Text = _testNode.Name;
            }

            testType.Text    = node.TestType;
            fullName.Text    = _testNode.FullName;
            description.Text = _testNode.GetProperty("Description");

            categories.Text = _testNode.GetPropertyList("Category");

            testCaseCount.Text = _testNode.TestCount.ToString();

            switch (_testNode.RunState)
            {
            case RunState.Explicit:
                shouldRun.Text = "Explicit";
                break;

            case RunState.Runnable:
                shouldRun.Text = "Yes";
                break;

            default:
                shouldRun.Text = "No";
                break;
            }

            ignoreReason.Text = _testNode.GetProperty("_SKIPREASON");

            FillPropertyList();

            FillPackageSettingsList();

            elapsedTime.Text = "Execution Time:";
            assertCount.Text = "Assert Count:";
            message.Text     = "";
            stackTrace.Text  = "";

            if (_resultNode != null)
            {
                elapsedTime.Text = string.Format("Execution Time: {0}", _resultNode.Duration);

                assertCount.Text = string.Format("Assert Count: {0}", _resultNode.AssertCount);

                // message may have a leading blank line
                // TODO: take care of this in label ?
                var messageText = _resultNode.Message;
                if (messageText != null)
                {
                    if (messageText.Length > 64000)
                    {
                        message.Text = TrimLeadingBlankLines(messageText.Substring(0, 64000));
                    }
                    else
                    {
                        message.Text = TrimLeadingBlankLines(messageText);
                    }
                }

                stackTrace.Text = _resultNode.StackTrace;
            }

            BeginPanel();

            CreateRow(testTypeLabel, testType);
            CreateRow(fullNameLabel, fullName);
            CreateRow(descriptionLabel, description);
            CreateRow(categoriesLabel, categories);
            CreateRow(testCaseCountLabel, testCaseCount, shouldRunLabel, shouldRun);
            CreateRow(ignoreReasonLabel, ignoreReason);
            CreateRow(propertiesLabel, hiddenProperties);
            CreateRow(properties);
            CreateRow(packageSettingsLabel);
            CreateRow(packageSettings);

            groupBox1.ClientSize = new Size(
                groupBox1.ClientSize.Width, maxY + 12);

            groupBox2.Location = new Point(
                groupBox1.Location.X, groupBox1.Bottom + 12);

            BeginPanel();

            CreateRow(elapsedTime, assertCount);
            CreateRow(messageLabel, message);
            CreateRow(stackTraceLabel);
            CreateRow(stackTrace);

            groupBox2.ClientSize = new Size(
                groupBox2.ClientSize.Width, this.maxY + 12);

            this.ClientSize = new Size(
                this.ClientSize.Width, groupBox2.Bottom + 12);

            Show();
        }
コード例 #42
0
		public void SetResult_Ignore()
		{
			TestSuiteTreeNode node = new TestSuiteTreeNode( testCaseInfo );
			TestResult result = new TestResult( testCaseInfo );

			result.Ignore( "reason" );
			node.Result = result;
			Assert.AreEqual( "MockTest1", node.Result.Name );
			Assert.AreEqual( TestSuiteTreeNode.IgnoredIndex, node.ImageIndex );
			Assert.AreEqual( TestSuiteTreeNode.IgnoredIndex, node.SelectedImageIndex );
			Assert.AreEqual( "Ignored", node.StatusText );
		}
コード例 #43
0
        private void CheckThatNodeMatchesTest(TestSuiteTreeNode node, Test test, string msg)
        {
            Assert.AreEqual(test.TestName, node.Test.TestName, "{0}: Names do not match for {1}", msg, test.TestName.FullName);

            if (test.IsSuite)
            {
                //if ( test.TestName.FullName == "NUnit.Tests.Assemblies.MockTestFixture" )
                //    foreach( TestSuiteTreeNode n in node.Nodes )
                //        Console.WriteLine( n.Test.TestName );

                Assert.AreEqual(test.Tests.Count, node.Nodes.Count, "{0}: Incorrect count for {1}", msg, test.TestName.FullName);

                for (int index = 0; index < test.Tests.Count; index++)
                {
                    CheckThatNodeMatchesTest((TestSuiteTreeNode)node.Nodes[index], (Test)test.Tests[index], msg);
                }
            }
        }
コード例 #44
0
        public void WhenResultIsCleared_IndexReflectsRunState(string testName, int expectedIndex)
		{
            Test test = TestFinder.Find(testName, testFixture, false);
			TestResult result = new TestResult( test );
			result.Failure("message", "stacktrace");

			TestSuiteTreeNode node = new TestSuiteTreeNode( result );
			Assert.AreEqual( TestSuiteTreeNode.FailureIndex, node.ImageIndex );
			Assert.AreEqual( TestSuiteTreeNode.FailureIndex, node.SelectedImageIndex );

			node.ClearResults();
			Assert.AreEqual( null, node.Result );
			Assert.AreEqual( expectedIndex, node.ImageIndex );
			Assert.AreEqual( expectedIndex, node.SelectedImageIndex );
		}
コード例 #45
0
		public void WhenResultIsCleared_NestedResultsAreAlsoCleared()
		{
			TestResult testCaseResult = new TestResult( testCase );
			testCaseResult.Success();
			TestResult testSuiteResult = new TestResult( testFixture );
			testSuiteResult.AddResult( testCaseResult );
            testSuiteResult.Success();

			TestSuiteTreeNode node1 = new TestSuiteTreeNode( testSuiteResult );
			TestSuiteTreeNode node2 = new TestSuiteTreeNode( testCaseResult );
			node1.Nodes.Add( node2 );

			Assert.AreEqual( TestSuiteTreeNode.SuccessIndex, node1.ImageIndex );
			Assert.AreEqual( TestSuiteTreeNode.SuccessIndex, node1.SelectedImageIndex );
			Assert.AreEqual( TestSuiteTreeNode.SuccessIndex, node2.ImageIndex );
			Assert.AreEqual( TestSuiteTreeNode.SuccessIndex, node2.SelectedImageIndex );

			node1.ClearResults();

			Assert.AreEqual( TestSuiteTreeNode.InitIndex, node1.ImageIndex );
			Assert.AreEqual( TestSuiteTreeNode.InitIndex, node1.SelectedImageIndex );
			Assert.AreEqual( TestSuiteTreeNode.InitIndex, node2.ImageIndex );
			Assert.AreEqual( TestSuiteTreeNode.InitIndex, node2.SelectedImageIndex );
		}
コード例 #46
0
        public void CanConstructFromTestFixture()
        {
			TestSuiteTreeNode node = new TestSuiteTreeNode( new TestInfo(testFixture) );
			Assert.AreEqual( "MockTestFixture", node.Text );
			Assert.AreEqual( "TestFixture", node.TestType );
        }
コード例 #47
0
        public void SetResult_Failure()
        {
            TestSuiteTreeNode node = new TestSuiteTreeNode( testCaseInfo );
            TestCaseResult result = new TestCaseResult( testCaseInfo );

            result.Failure("message", "stacktrace");
            node.Result = result;
            Assert.AreEqual( TestSuiteTreeNode.FailureIndex, node.ImageIndex );
            Assert.AreEqual( TestSuiteTreeNode.FailureIndex, node.SelectedImageIndex );
            Assert.AreEqual( "Failure", node.StatusText );
        }
コード例 #48
0
        public void CanConstructFromTestCase()
        {
			TestSuiteTreeNode node = new TestSuiteTreeNode( new TestInfo(testCase) );
			Assert.AreEqual( "MockTest1", node.Text );
			Assert.AreEqual( "TestMethod", node.TestType );
		}