public TestResult RunTest(TestMethod method)
        {
            TestResult res = new TestResult();
            res.Passed = PassTests;

            return res;
        }
        public void ErrorVisibility_Will_Return_Visibility_Visible_If_Test_Failed_Test()
        {
            TestResult result = new TestResult();
            result.Passed = false;
            TestResultViewModel viewModel = new TestResultViewModel(result);

            Confirm.Equal(Visibility.Visible, viewModel.ErrorVisibility);
        }
        public void ErrorVisibility_Will_Return_Visibility_Colapsed_If_Test_Passed_Test()
        {
            TestResult result = new TestResult();
            result.Passed = true;
            TestResultViewModel viewModel = new TestResultViewModel(result);

            Confirm.Equal(Visibility.Collapsed, viewModel.ErrorVisibility);
        }
        public void DurationVisibility_Will_Return_Visibility_Visible_If_Test_Passed_Test()
        {
            TestResult result = new TestResult();
            result.Passed = true;
            TestResultViewModel viewModel = new TestResultViewModel(result);

            Confirm.Equal(Visibility.Visible, viewModel.DurationVisibility);
        }
        public void DurationVisibility_Will_Return_Visibility_Colapsed_If_Test_Failed_Test()
        {
            TestResult result = new TestResult();
            result.Passed = false;
            TestResultViewModel viewModel = new TestResultViewModel(result);

            Confirm.Equal(Visibility.Collapsed, viewModel.DurationVisibility);
        }
 public void AddResultControl(TestResult res)
 {
     Dispatcher.Invoke(DispatcherPriority.Normal,
             new Action(
                 delegate()
                 {
                     TestResultControl resultControl = new TestResultControl();
                     resultControl.Initialize(res);
                     resultPanel.Children.Add(resultControl);
                 }
                 ));
 }
 public void Initialize(TestResult result)
 {
     this.DataContext = new TestResultViewModel(result);
     this.TestResult = result;
 }
        public void TestResultViewModels_Will_Return_TestResultViewModels_Based_On_Test_Results_Test()
        {
            TestMethodViewModel vm = new TestMethodViewModel(AddResultControl, ClearResultControl);
            vm.TestResults = new List<TestResult>();

            TestResult r1 = new TestResult();
            r1.Passed = true;
            r1.TestName = "Test1";
            vm.TestResults.Add(r1);

            r1 = new TestResult();
            r1.Passed = true;
            r1.TestName = "Test2";
            vm.TestResults.Add(r1);

            Confirm.Equal(2, vm.TestResultViewModels.Count);
            Confirm.Equal("Test1", vm.TestResultViewModels[0].TestResult.TestName);
            Confirm.Equal("Test2", vm.TestResultViewModels[1].TestResult.TestName);
        }
 public void AddResultControl(TestResult res)
 {
 }
 public TestResultViewModel(TestResult result)
 {
     testResult = result;
     Initialize();
 }
Example #11
0
        private TestResult HandleFailedTest(MemberInfo m, TimeSpan duration, Exception ex)
        {
            TestResult result = new TestResult();
            result.Duration = duration;

            if (AttributeManager.ExceptionIsExcepted(m, ex))
            {
                result.Passed = true;
                result.ResultText = GetTestPassedMessage(m.Name);
                return result;
            }

            if (ex.InnerException != null)
            {
                result.Passed = false;
                UnitTestFailedException failEx = ex.InnerException as UnitTestFailedException;

                if (failEx != null)
                {
                    result.ResultText = failEx.Message;
                    result.Exception = failEx;
                }
                else
                {
                    result.ResultText = ex.InnerException.Message;
                    result.Exception = ex.InnerException;
                }
            }
            else
            {
                result.ResultText = ex.Message;
                result.Exception = ex;
            }
            return result;
        }
Example #12
0
        private TestResult EnsureCorrectTestResult(MemberInfo method)
        {
            TestResult result = new TestResult();

            object[] attribute = method.GetCustomAttributes(typeof(ExceptionThrown), true);

            if (attribute.Length > 0)
            {
                ExceptionThrown expectedException = attribute[0] as ExceptionThrown;
                result.Passed = false;
                result.ResultText = string.Format("Exception of type {0} was expected", expectedException.ExceptionType);
                return result;
            }

            result.Passed = true;
            result.ResultText = GetTestPassedMessage(method.Name);
            return result;
        }
        public void SectionVisibilityCommand_Will_Fire_And_Toggle_Detail_Section_To_Visible_Test()
        {
            TestResult result = new TestResult();
            result.Passed = true;
            TestResultViewModel viewModel = new TestResultViewModel(result);

            viewModel.SectionVisibilityCommand.Execute(null);
            Confirm.Equal(Visibility.Visible, viewModel.IsDetailedSectionVisibile);
        }
        public void IsDetailedSectionVisibile_Is_Colapsed_By_Default_Test()
        {
            TestResult result = new TestResult();
            result.Passed = true;
            TestResultViewModel viewModel = new TestResultViewModel(result);

            Confirm.Equal(Visibility.Collapsed, viewModel.IsDetailedSectionVisibile);
        }
        private void AddTestResult(TestResult res, TestMethod method)
        {
            lock (testResultLock)
            {
                if (res.Passed == true)
                {
                    method.Color = "Green";
                    TestsPassed++;
                }
                else
                {
                    method.Color = "Red";
                    TestsFailed++;
                }

                this.addResultControl(res);
                this.TestResults.Add(res);

                xmlReportSaved = false;

                string summaryLine = String.Format("{0} / {1} Tests Run - {2} Succeeded - {3} Failed", TestsPassed + TestsFailed, TotalTestCount, TestsPassed, TestsFailed);
                string resultString = res.ToString();

                int lineSize = Math.Max(summaryLine.Length, resultString.Length);

                StringBuilder resultOutput = new StringBuilder();
                resultOutput.AppendLine(String.Empty.PadRight(lineSize, '*'));
                resultOutput.AppendLine(summaryLine);
                resultOutput.AppendLine(resultString);
                resultOutput.AppendLine(String.Empty.PadRight(lineSize, '*'));

                if (testsFailed > 0)
                {
                    resultOutput.AppendLine("Failed tests:");
                    var failedTests = testResults.Where(t => t.Passed == false);
                    foreach(var test in failedTests)
                    {
                        resultOutput.AppendLine(test.ToString());
                    }
                    resultOutput.AppendLine(String.Empty.PadRight(lineSize, '*'));
                }

                Console.WriteLine(resultOutput.ToString());
            }
        }