示例#1
0
        public void AddTabbedPageOnRunTime()
        {
            //Arrange
            var navigationService = LocatorService.Instance.Resolve <INavigationService>();
            var pageContainers    = new List <PageContainer>
            {
                new PageContainer()
                {
                    IsNavigationPage = true, Parameter = "Home Page", ViewModel = new HomeViewModel()
                },
                new PageContainer()
                {
                    IsNavigationPage = false, Parameter = "Page One", ViewModel = new View1ViewModel()
                },
                new PageContainer()
                {
                    IsNavigationPage = false, Parameter = "Page two", ViewModel = new View2ViewModel()
                }
            };
            var newPage = new PageContainer()
            {
                IsNavigationPage = false,
                Parameter        = "Page three",
                ViewModel        = new View3ViewModel()
            };

            //Act
            MockApp.SetHomePage(pageContainers);
            var isPageAdded = navigationService.AddPageToTabbedPage(newPage);

            //Assert
            Assert.IsTrue(isPageAdded);
        }
示例#2
0
        public void InitializeAppNavigationWithTabbedPage()
        {
            //Arrange
            var pageContainers = new List <PageContainer>
            {
                new PageContainer()
                {
                    IsNavigationPage = true, Parameter = "Home Page", ViewModel = new HomeViewModel()
                },
                new PageContainer()
                {
                    IsNavigationPage = false, Parameter = "Page One", ViewModel = new View1ViewModel()
                },
                new PageContainer()
                {
                    IsNavigationPage = false, Parameter = "Page two", ViewModel = new View2ViewModel()
                },
                new PageContainer()
                {
                    IsNavigationPage = false, Parameter = "Page three", ViewModel = new View3ViewModel()
                }
            };
            var app = new MockApp();

            //Act
            MockApp.SetHomePage(pageContainers);
            //Assert
            var tabbedIsExists = app.MainPage.GetType() == typeof(TabbedPage);

            Assert.IsTrue(tabbedIsExists);
        }
示例#3
0
        public void ChangeDetailPageInMasterDetailTest()
        {
            //Arrange
            var masterPage = new PageContainer()
            {
                IsNavigationPage = true,
                Parameter        = "Master Page",
                ViewModel        = LocatorService.Instance.Resolve <HomeViewModel>()
            };
            var detailPage = new PageContainer()
            {
                IsNavigationPage = true,
                Parameter        = "Detail Page",
                ViewModel        = LocatorService.Instance.Resolve <HomeViewModel>()
            };
            var newDetailPage = new PageContainer()
            {
                IsNavigationPage = true,
                Parameter        = "New Detail Page",
                ViewModel        = LocatorService.Instance.Resolve <HomeViewModel>()
            };
            var navigationService = LocatorService.Instance.Resolve <INavigationService>();

            //Act
            MockApp.SetHomePage(masterPage, detailPage);
            var isDetailPageChanged = navigationService.ChangeDetailPage(newDetailPage, null);

            //Assert
            Assert.IsTrue(isDetailPageChanged);
        }
示例#4
0
        public void NavigateToMasterDetailPage()
        {
            //Arrange
            var app        = new MockApp();
            var masterPage = new PageContainer()
            {
                IsNavigationPage = true,
                Parameter        = "Master Page",
                ViewModel        = LocatorService.Instance.Resolve <HomeViewModel>()
            };
            var detailPage = new PageContainer()
            {
                IsNavigationPage = true,
                Parameter        = "Detail Page",
                ViewModel        = LocatorService.Instance.Resolve <HomeViewModel>()
            };;
            var navigationService = LocatorService.Instance.Resolve <INavigationService>();

            //Act
            MockApp.SetHomePage <HomeViewModel>();
            var pushMasterDetailsTask = navigationService.NavigateToMasterDetailsAsync(masterPage, detailPage);
            var isMasterDetailExists  = ModalStack.Any(x => x.GetType() == typeof(MasterDetailPage)) ||
                                        NavigationStack.Any(x => x.GetType() == typeof(MasterDetailPage));

            //Assert
            Assert.IsTrue(pushMasterDetailsTask.IsCompleted);
            Assert.IsTrue(isMasterDetailExists);
        }
示例#5
0
        public void InitializeAppNavigationWithContentPage()
        {
            //Arrange
            var app = new MockApp();

            //Act
            MockApp.SetHomePage <HomeViewModel>();
            //Assert
            var homePage = app.MainPage.BindingContext.GetType() == typeof(HomeViewModel);

            Assert.IsNotNull(homePage);
        }
示例#6
0
        public void NavigateTo_WithOutParameter()
        {
            //Arrange
            var navigationService = LocatorService.Instance.Resolve <INavigationService>();

            //Act
            MockApp.SetHomePage <View1ViewModel>(isNavigationPage: true);
            navigationService.NavigateToAsync <HomeViewModel>();
            //Assert
            var homePage = Application.Current.MainPage.Navigation.NavigationStack.LastOrDefault(x => x.GetType() == typeof(HomePage));

            Assert.IsNotNull(homePage);
        }
示例#7
0
        public void NavigateToModal_WithParameter()
        {
            //Arrange
            var navigationService = LocatorService.Instance.Resolve <INavigationService>();

            //Act
            MockApp.SetHomePage <View1ViewModel>();
            navigationService.NavigateToModalAsync <HomeViewModel>("Hello Test");
            var homePage      = MockApp.Current.MainPage.Navigation.ModalStack.LastOrDefault(x => x.GetType() == typeof(HomePage));
            var homeViewModel = (HomeViewModel)homePage?.BindingContext;

            //Assert
            Assert.IsNotNull(homePage);
            Assert.IsTrue((string)homeViewModel?.NavigationData == "Hello Test");
        }
        public void NavigateToTabbedPage()
        {
            //Arrange
            var pageContainers = new List <PageContainer>
            {
                new PageContainer()
                {
                    IsNavigationPage = true,
                    Parameter        = "Home Page",
                    ViewModel        = BaseLocator.Instance.Resolve <HomeViewModel>()
                },
                new PageContainer()
                {
                    IsNavigationPage = false,
                    Parameter        = "Page One",
                    ViewModel        = BaseLocator.Instance.Resolve <View1ViewModel>()
                },
                new PageContainer()
                {
                    IsNavigationPage = false,
                    Parameter        = "Page two",
                    ViewModel        = BaseLocator.Instance.Resolve <View2ViewModel>()
                },
                new PageContainer()
                {
                    IsNavigationPage = false,
                    Parameter        = "Page three",
                    ViewModel        = BaseLocator.Instance.Resolve <View3ViewModel>()
                }
            };
            var navigationService = BaseLocator.Instance.Resolve <INavigationService>();
            var app = new MockApp();

            //Act
            app.SetHomePage <HomeViewModel>();
            var navigateToTabbedAsyncTask = navigationService.NavigateToTabbedAsync(pageContainers);
            var isTabbedExists            = ModalStack.Any(x => x.GetType() == typeof(TabbedPage)) ||
                                            NavigationStack.Any(x => x.GetType() == typeof(TabbedPage));

            //Assert
            Assert.IsTrue(navigateToTabbedAsyncTask.IsCompleted);
            Assert.IsTrue(isTabbedExists);
        }
示例#9
0
        public void InitializeAppNavigationWithMasterDetialPage()
        {
            //Arrange
            var detialPage = new PageContainer()
            {
                IsNavigationPage = true, Parameter = "Detail Page", ViewModel = new HomeViewModel(), PageName = "Detail Page"
            };
            var masterPage = new PageContainer()
            {
                IsNavigationPage = false, Parameter = "Master Page", ViewModel = new View1ViewModel(), PageName = "Master Page"
            };

            Application.Current = new MockApp();
            //Act
            MockApp.SetHomePage(masterPage, detialPage);
            //Assert
            var masterIsExists = Application.Current.MainPage.GetType() == typeof(MasterDetailPage);

            Assert.IsTrue(masterIsExists);
        }