Esempio n. 1
0
        public async Task OneTimeSetup()
        {
            Xamarin.Forms.Mocks.MockForms.Init();
            navController = new NavController();
            await navController.InitAsync(new TestPage0());

            await navController.PushAsync <TestViewModel1>();

            await navController.PushAsync <TestViewModel2>();

            await navController.PushAsync <TestViewModel3>();
        }
        public async Task OnAppearing_runs_after_CollapseMainStack()
        {
            navController = new NavController();
            await navController.InitAsync(new TestPage3());

            await navController.PushAsync <TestViewModel2>();

            await navController.PushAsync <TestViewModel1>();

            await navController.CollapseMainStack();

            Assume.That(navController.RootViewModel is TestViewModel1);
            var vm = navController.RootViewModel as TestViewModel1;

            Assert.AreEqual(2, vm.OnAppearingRuns);
        }
        public async Task OnAppearing_runs_after_PopToRootAsync(bool isAnimated)
        {
            navController = new NavController();
            await navController.InitAsync(new TestPage1());

            await navController.PushAsync <TestViewModel2>();

            await navController.PushAsync <TestViewModel3>();

            await navController.PopToRootAsync(isAnimated);

            Assume.That(navController.RootViewModel is TestViewModel1);
            var vm = navController.RootViewModel as TestViewModel1;

            Assert.IsTrue(vm.OnAppearingRuns == 2);
        }
        public async Task OnAppearing_doesnt_runs_after_PopAsync_if_modal(bool isAnimated)
        {
            navController = new NavController();
            await navController.InitAsync(new TestPage1());

            await navController.PushAsync <TestViewModel2>();

            await navController.PushModalAsync <TestViewModel3>();

            await navController.PopAsync(isAnimated);

            var vm = navController.MainStack.GetCurrentViewModel();

            Assume.That(vm is TestViewModel1);
            Assert.AreEqual(1, (vm as TestViewModel1).OnAppearingRuns);
        }
        public async Task OnAppearing_doesnt_run_after_PopToRootAsync_if_modal(bool isAnimated)
        {
            navController = new NavController();
            await navController.InitAsync(new TestPage1());

            await navController.PushAsync <TestViewModel2>();

            await navController.PushModalAsync <TestViewModel3>();

            await navController.PopToRootAsync(isAnimated);

            Assume.That(navController.RootViewModel is TestViewModel1);
            var vm = navController.RootViewModel as TestViewModel1;

            Assert.AreEqual(1, vm.OnAppearingRuns);
        }
        public async Task SetNamingConventions_subNameSpace()
        {
            NavController.SetNamingConventions("Vms", "Pages");
            navController = new NavController();
            await navController.InitAsync(new Pages.TestVmsPage());

            Assert.IsInstanceOf <Vms.TestVmsViewModel>(navController.RootViewModel);

            await navController.PushAsync <Vms.TestVmsViewModel>();

            Assert.Multiple(() =>
            {
                Assert.AreEqual(2, navController.MainStack.Count);
                Assert.IsInstanceOf <Pages.TestVmsPage>(navController.TopPage);
            });
        }
        public async Task SetNamingConventions_suffix()
        {
            NavController.SetNamingConventions(viewModelSuffix: "Vm", viewSuffix: "Pg");
            navController = new NavController();
            await navController.InitAsync(new TestPg0());

            Assert.IsInstanceOf <TestVm0>(navController.RootViewModel);

            await navController.PushAsync <TestVm0>();

            Assert.Multiple(() =>
            {
                Assert.AreEqual(2, navController.MainStack.Count);
                Assert.IsInstanceOf <TestPg0>(navController.TopPage);
            });
        }
        public async Task OnAppearing_runs_after_PopAsync(bool isAnimated)
        {
            await navController.PushAsync <TestViewModel1>();

            await navController.PushAsync <TestViewModel2>();

            await navController.PopAsync(isAnimated);

            Assume.That(navController.TopViewModel is TestViewModel1);
            var vm = navController.TopViewModel as TestViewModel1;

            Assert.IsTrue(vm.OnAppearingRuns == 2);
        }
 public void NotInitializedException_PushAsync()
 {
     Assert.ThrowsAsync <NotInitializedException>(async() => { await navController.PushAsync <TestViewModel0>(); });
 }