public void Init()
        {
            base.InitBase();

            project = new MockCSharpProject();
            context.MockUnitTestsPad.AddProject(project);

            string[] methodNames = new string[] { "FirstTest", "SecondTest", "ThirdTest" };

            testProject =
                TestProjectHelper.CreateTestProjectWithTestClassTestMethods(project,
                                                                            "MyTests.MyTestClass",
                                                                            methodNames);

            TestClass testClass = testProject.TestClasses[0];

            firstTestMethod  = testClass.TestMethods[0];
            secondTestMethod = testClass.TestMethods[1];
            thirdTestMethod  = testClass.TestMethods[2];

            context.MockUnitTestsPad.AddTestProject(testProject);

            MockBuildProjectBeforeTestRun buildProjectBeforeTestRun = new MockBuildProjectBeforeTestRun();

            context.MockBuildProjectFactory.AddBuildProjectBeforeTestRun(buildProjectBeforeTestRun);

            context.UnitTestingOptions.NoThread            = true;
            context.UnitTestingOptions.NoShadow            = true;
            context.UnitTestingOptions.NoLogo              = true;
            context.UnitTestingOptions.NoDots              = true;
            context.UnitTestingOptions.Labels              = true;
            context.UnitTestingOptions.CreateXmlOutputFile = true;

            testFramework = new MockTestFramework();
            context.MockRegisteredTestFrameworks.AddTestFrameworkForProject(project, testFramework);

            runTestCommand.Run();

            buildProjectBeforeTestRun.FireBuildCompleteEvent();

            errorTestResult            = new TestResult("MyTests.MyTestClass.FirstTest");
            errorTestResult.ResultType = TestResultType.Failure;

            warningTestResult            = new TestResult("MyTests.MyTestClass.SecondTest");
            warningTestResult.ResultType = TestResultType.Ignored;

            successTestResult            = new TestResult("MyTests.MyTestClass.ThirdTest");
            successTestResult.ResultType = TestResultType.Success;

            context.MockUnitTestWorkbench.MakeSafeThreadAsyncMethodCallsWithArguments = true;
            MockTestRunner testRunner = runTestCommand.TestRunnersCreated[0];

            testRunner.FireTestFinishedEvent(errorTestResult);
            testRunner.FireTestFinishedEvent(warningTestResult);
            testRunner.FireTestFinishedEvent(successTestResult);

            context.MockUnitTestsPad.IsUpdateToolbarMethodCalled = false;
            runningTestsBeforeTestsFinishedCalled = AbstractRunTestCommand.IsRunningTest;
            runTestCommand.CallTestsCompleted();
        }
Ejemplo n.º 2
0
        public void FireTestFinishedEventTriggersTestFinishedEvent()
        {
            TestResult expectedResult = new TestResult("abc");
            TestResult result         = null;

            testRunner.TestFinished +=
                delegate(object source, TestFinishedEventArgs e) {
                result = e.Result;
            };

            testRunner.FireTestFinishedEvent(expectedResult);

            Assert.AreEqual(expectedResult, result);
        }