public void TestOnItemSelectedWithSelectedItemTestWithChildTestsPushesTestsPageToStackAndCaches() { NUnitRunner runner = new NUnitRunner("runner-name"); runner.AddTestAssembly(typeof(TestFixtureStubOne).Assembly); ITest firstTestInstance = runner.ExploreTests(); ITest secondTestInstance = runner.ExploreTests(); TestsViewModel firstTest = new TestsViewModel(runner, firstTestInstance); TestsViewModel secondTest = new TestsViewModel(runner, secondTestInstance); Assert.IsTrue(firstTest.Test.IsSuite); Assert.IsTrue(firstTest.Test.HasChildren); Assert.IsTrue(secondTest.Test.IsSuite); Assert.IsTrue(secondTest.Test.HasChildren); SelectedItemChangedEventArgs firstArgs = new SelectedItemChangedEventArgs(firstTest, 0); SelectedItemChangedEventArgs secondArgs = new SelectedItemChangedEventArgs(secondTest, 0); TestsPageForTest page = new TestsPageForTest(runner); // Load first page page.InvokeOnItemSelected(null, firstArgs); Assert.AreEqual(1, page.NavigationStack.Count); TestsPage firstTestsPage = page.NavigationStack.First() as TestsPage; Assert.IsNotNull(firstTestsPage); Assert.AreEqual(firstTest, firstTestsPage.ViewModel); Assert.AreEqual(runner, firstTestsPage.ViewModel.TestRunner); Assert.AreEqual(firstTestInstance, firstTestsPage.ViewModel.Test); // Load second page page.InvokeOnItemSelected(null, secondArgs); Assert.AreEqual(2, page.NavigationStack.Count); TestsPage secondTestsPage = page.NavigationStack[1] as TestsPage; Assert.IsNotNull(secondTestsPage); Assert.AreEqual(secondTest, secondTestsPage.ViewModel); Assert.AreEqual(runner, secondTestsPage.ViewModel.TestRunner); Assert.AreEqual(secondTestInstance, secondTestsPage.ViewModel.Test); // Load first page again IList <Page> expectedStack = new List <Page>(page.NavigationStack); expectedStack.Add(firstTestsPage); page.InvokeOnItemSelected(null, firstArgs); Assert.AreEqual(3, page.NavigationStack.Count); Assert.AreSame(firstTestsPage, page.NavigationStack[2]); CollectionAssert.AreEqual(expectedStack, page.NavigationStack); }
public void TestExploreTestsWithAssemblyReturnsLoadedTestCases([Values] bool withChildTests, [Values] bool withFilter) { ITestFilter filter = withFilter ? NUnitFilter.Where.Class(typeof(TestFixtureStubOne).FullName).And.Method("Test2").Build().Filter : null; INUnitRunner runner = new NUnitRunner("suite-name"); Assembly assembly = typeof(TestFixtureStubOne).Assembly; int expected = 0; if (withChildTests) { expected = withFilter ? 1 : TestFixtureStubHelper.GeTestFixtureStub().TestCount; Task <ITest> testTask = runner.AddTestAssemblyAsync(assembly); testTask.Wait(); } ITest test = runner.ExploreTests(assembly, filter); if (withChildTests) { Assert.IsNotNull(test); Assert.AreEqual(expected, test.TestCaseCount); } else { Assert.IsNull(test); } }
public void TestExploreTestsThrowsArgumentNullExceptionWhenAssemblyIsNull() { INUnitRunner runner = new NUnitRunner("suite-name"); Assert.Throws( Is.TypeOf <ArgumentNullException>().And.Message .EqualTo("The assembly cannot be null. (Parameter 'assembly')"), () => runner.ExploreTests(null, null)); }