public void TestReloadResultsCommandReturnsImmediatelyWhenTestRunnerIsRunningTests() { int invocationCount = 0; NUnitSuiteForTest suite = new NUnitSuiteForTest("suite-name"); TestAssemblyRunnerForTest assemblyRunner = new TestAssemblyRunnerForTest(); assemblyRunner.IsTestRunning = true; suite.RunnerToLoad = assemblyRunner; NUnitRunnerForTest runner = new NUnitRunnerForTest(suite); runner.AddTestAssembly(GetType().Assembly); runner.AddTestAssembly(typeof(TestFixtureStubOne).Assembly); Assert.AreEqual(2, runner.TestSuite.TestAssemblyRunners.Count); TestsViewModel model = new TestsViewModel(runner, runner.TestSuite); model.PropertyChanged += (sender, args) => { if (args.PropertyName.Equals("IsBusy")) { invocationCount++; } }; model.ReloadResultsCommand.Execute(null); WaitForCommand(model); Assert.IsFalse(model.IsBusy); Assert.AreEqual(2, invocationCount); CollectionAssert.IsEmpty(model.Tests); }
TestRunTestsAsyncWithAlreadyRunningTestWaitsForPreviousCompletionAndThenRunsTestsAndReturnsTheRanTests() { TestListenerForTest listener = new TestListenerForTest(); NUnitSuiteForTest suite = new NUnitSuiteForTest("suite-name"); TestAssemblyRunnerForTest assemblyRunner = new TestAssemblyRunnerForTest(); assemblyRunner.IsTestLoaded = true; assemblyRunner.IsTestRunning = true; suite.RunnerToLoad = assemblyRunner; NUnitRunnerForTest runner = new NUnitRunnerForTest(suite); Assembly assembly = typeof(TestFixtureStubOne).Assembly; int expectedCaseCount = TestFixtureStubHelper.GeTestFixtureStub().ResultsDepth + TestFixtureStubHelper.GeTestFixtureStub().ResultCount; int expectedResultCount = TestFixtureStubHelper.GeTestFixtureStub().TestCount; Task <ITest> testTask = runner.AddTestAssemblyAsync(assembly); testTask.Wait(); Assert.IsTrue(runner.IsTestRunning); Assert.IsFalse(runner.IsTestComplete); Task <ITestResult> testsTask = runner.RunTestsAsync(listener); Assert.IsNotNull(testsTask); Assert.IsTrue(runner.IsTestRunning); Assert.IsFalse(runner.IsTestComplete); Thread.Sleep(50); assemblyRunner.IsTestRunning = false; testsTask.Wait(); ITestResult results = testsTask.Result; Assert.IsFalse(runner.IsTestRunning); Assert.IsTrue(runner.IsTestComplete); Assert.IsNotNull(results); Assert.IsFalse(runner.IsTestRunning); Assert.IsTrue(runner.IsTestComplete); Assert.AreEqual(ResultState.ChildFailure, results.ResultState); int totalResultCount = results.FailCount + results.InconclusiveCount + results.PassCount + results.SkipCount + results.WarningCount; Assert.AreEqual(expectedResultCount, totalResultCount); Assert.AreEqual(expectedCaseCount, listener.Tests.Count); }