Exemplo n.º 1
0
        public async void StopAutoPageDisposal_ShouldNotDisposeWhenPopped()
        {
            // creating the test page/viewmodel
            var page          = new TestPage();
            var testViewModel = new TestViewModel();

            page.BindingContext = testViewModel;

            // adding a main page to the navigation stack, because the root will not be popped
            var navigation = new AutoNavigationPage(new Page());

            //start the automatic disposal
            navigation.StartAutoPageDisposal();
            //push the test page onto the navigation stack
            await navigation.PushAsync(page);

            // stop the autmatic disposal
            navigation.StopAutoPageDisposal();
            //pop the test page from the navigation stack
            await navigation.PopAsync();

            // Assert that both page and viewmodel did not call their Dispose method.
            Assert.False(testViewModel.IsDisposed);
            Assert.False(page.IsDisposed);
        }
Exemplo n.º 2
0
        public async void StartAutoPageDisposal_ShouldDisposeWhenRemoved()
        {
            // creating the test page/viewmodel
            var page          = new TestPage();
            var testViewModel = new TestViewModel();

            page.BindingContext = testViewModel;

            // adding a main page to the navigation stack, because the root will not be popped
            var navigation = new AutoNavigationPage(new Page());
            //push the test page onto the navigation stack
            await navigation.PushAsync(page);

            //start the automatic disposal
            navigation.StartAutoPageDisposal();
            // remove the page
            navigation.Navigation.RemovePage(page);

            // Assert that both page and viewmodel called their Dispose methods.
            Assert.True(testViewModel.IsDisposed);
            Assert.True(page.IsDisposed);
        }