public void TestRunTestsAsyncWithAssemblyRunsTestsAndReturnsTheRanTests([Values] bool withChildTests, [Values] bool withListener, [Values] bool withFilter) { ITestFilter filter = withFilter ? NUnitFilter.Where.Class(typeof(TestFixtureStubOne).FullName).And.Method("Test2").Build().Filter : null; ResultState expectedState = ResultState.Inconclusive; if (withChildTests) { expectedState = withFilter ? ResultState.Success : ResultState.ChildFailure; } TestListenerForTest listener = withListener ? new TestListenerForTest() : null; INUnitRunner runner = new NUnitRunner("suite-name"); Assembly assembly = typeof(TestFixtureStubOne).Assembly; int expectedCaseCount = 0; int expectedResultCount = 0; if (withChildTests) { expectedCaseCount = TestFixtureStubHelper.GeTestFixtureStub().ResultsDepth + (withFilter ? 2 : TestFixtureStubHelper.GeTestFixtureStub().ResultCount); expectedResultCount = withFilter ? 1 : TestFixtureStubHelper.GeTestFixtureStub().TestCount; Task <ITest> testTask = runner.AddTestAssemblyAsync(assembly); testTask.Wait(); } Task <ITestResult> testsTask = runner.RunTestsAsync(assembly, listener, filter); Assert.IsNotNull(testsTask); testsTask.Wait(); ITestResult results = testsTask.Result; if (withChildTests) { Assert.IsNotNull(results); Assert.IsFalse(runner.IsTestRunning); Assert.IsTrue(runner.IsTestComplete); Assert.AreEqual(expectedState, results.ResultState); int totalResultCount = results.FailCount + results.InconclusiveCount + results.PassCount + results.SkipCount + results.WarningCount; Assert.AreEqual(expectedResultCount, totalResultCount); if (withListener) { Assert.AreEqual(expectedCaseCount, listener.Tests.Count); } } else { Assert.IsNull(results); } }
public void TestRunTestsAsyncThrowsArgumentNullExceptionWhenAssemblyIsNull() { INUnitRunner runner = new NUnitRunner("suite-name"); Assert.ThrowsAsync( Is.TypeOf <ArgumentNullException>().And.Message .EqualTo("The assembly cannot be null. (Parameter 'assembly')"), async() => await runner.RunTestsAsync(null, null, null)); }