public void TestListViewMenuOnItemSelectedNavigatesToNewPage([Values] MenuItemType start,
                                                                     [Values] MenuItemType end)
        {
            SelectedItemChangedEventArgs arg =
                new SelectedItemChangedEventArgs(new HomeMenuItem {
                Id = end, Title = "Title"
            }, 0);

            MainPage mainPage  = new MainPageForTest(null);
            Page     startPage = null;
            Type     expected  = null;

            switch (start)
            {
            case MenuItemType.Tests:
                startPage = new TestsPage(null, null, false);
                expected  = typeof(TestsPage);
                break;

            case MenuItemType.About:
                startPage = new AboutPage(false);
                expected  = typeof(AboutPage);
                break;

            default:
                Assert.Fail($" MenuItemType {start} is not supported by this test.");
                break;
            }

            switch (end)
            {
            case MenuItemType.Tests:
                expected = typeof(TestsPage);
                break;

            case MenuItemType.About:
                expected = typeof(AboutPage);
                break;

            default:
                Assert.Fail($" MenuItemType {end} is not supported by this test.");
                break;
            }

            mainPage.Detail = new NavigationPage(startPage);

            MenuPageForTest page = new MenuPageForTest(mainPage);

            Task task = page.InvokeListViewMenuOnItemSelected(this, arg);

            Assert.IsNotNull(task);
            task.Wait();

            Page navPage = (mainPage.Detail as NavigationPage)?.RootPage;

            Assert.IsNotNull(navPage);
            Assert.AreEqual(expected, navPage.GetType());
        }
        public void TestNavigateFromMenuNavigatesToNewPage([Values] MenuItemType start,
                                                           [Values] MenuItemType end, [Values] bool isAndroid)
        {
            MainPageForTest page = new MainPageForTest(null);

            if (isAndroid)
            {
                page.DevicePlatform = "Android";
            }

            Page startPage = null;
            Type expected  = null;

            switch (start)
            {
            case MenuItemType.Tests:
                startPage = new TestsPage(null, null, false);
                expected  = typeof(TestsPage);
                break;

            case MenuItemType.About:
                startPage = new AboutPage(false);
                expected  = typeof(AboutPage);
                break;

            default:
                Assert.Fail($" MenuItemType {start} is not supported by this test.");
                break;
            }

            switch (end)
            {
            case MenuItemType.Tests:
                expected = typeof(TestsPage);
                break;

            case MenuItemType.About:
                expected = typeof(AboutPage);
                break;

            default:
                Assert.Fail($" MenuItemType {end} is not supported by this test.");
                break;
            }

            page.Detail = new NavigationPage(startPage);

            Task task = page.NavigateFromMenu(end);

            Assert.IsNotNull(task);
            task.Wait();

            Page currentPage = page.Detail;
            Page navPage     = (page.Detail as NavigationPage)?.RootPage;

            Assert.IsNotNull(navPage);
            Assert.AreEqual(expected, navPage.GetType());

            task = page.NavigateFromMenu(end);
            Assert.IsNotNull(task);
            task.Wait();

            navPage = (page.Detail as NavigationPage)?.RootPage;
            Assert.IsNotNull(navPage);
            Assert.AreEqual(expected, navPage.GetType());
            Assert.AreSame(currentPage, page.Detail);
        }