Пример #1
0
        public void ContentPage()
        {
            var eventRecoder    = new EventRecorder();
            var viewModelMock   = new ViewModelMock(eventRecoder);
            var contentPageMock = new ContentPageMock(eventRecoder)
            {
                BindingContext = viewModelMock
            };

            LifecycleNoticeService.OnResume(new ApplicationMock {
                MainPage = contentPageMock
            });

            Assert.Equal(2, eventRecoder.Count);

            Assert.NotNull(eventRecoder[0]);
            Assert.Equal(contentPageMock, eventRecoder[0].Sender);
            Assert.Equal("OnResume", eventRecoder[0].CallerMemberName);
            Assert.Null(eventRecoder[0].Parameter);

            Assert.NotNull(eventRecoder[1]);
            Assert.Equal(viewModelMock, eventRecoder[1].Sender);
            Assert.Equal("OnResume", eventRecoder[1].CallerMemberName);
            Assert.Null(eventRecoder[1].Parameter);
        }
Пример #2
0
        public void OnResume_WithModalStackPages()
        {
            var eventRecorder    = new EventRecorder();
            var contentPageMock1 = new ContentPageMock(eventRecorder);

            var application = new ApplicationMock {
                MainPage = contentPageMock1
            };

            var contentPageMock2 = new ContentPageMock(eventRecorder);

            contentPageMock1.Navigation.PushModalAsync(contentPageMock2);

            var contentPageMock3 = new ContentPageMock(eventRecorder);

            contentPageMock2.Navigation.PushModalAsync(contentPageMock3);

            LifecycleNoticeService.OnResume(application);

            Assert.Equal(3, eventRecorder.Count);

            Assert.Equal(contentPageMock1, eventRecorder[0].Sender);
            Assert.Equal("OnResume", eventRecorder[0].CallerMemberName);
            Assert.Null(eventRecorder[0].Parameter);

            Assert.Equal(contentPageMock2, eventRecorder[1].Sender);
            Assert.Equal("OnResume", eventRecorder[1].CallerMemberName);
            Assert.Null(eventRecorder[1].Parameter);

            Assert.Equal(contentPageMock3, eventRecorder[2].Sender);
            Assert.Equal("OnResume", eventRecorder[2].CallerMemberName);
            Assert.Null(eventRecorder[2].Parameter);
        }
Пример #3
0
        public void OnResume()
        {
            var eventRecorder   = new EventRecorder();
            var contentPageMock = new ContentPageMock(eventRecorder);

            var application = new ApplicationMock {
                MainPage = contentPageMock
            };

            LifecycleNoticeService.OnResume(application);

            Assert.Equal(1, eventRecorder.Count);
            Assert.Equal(contentPageMock, eventRecorder[0].Sender);
            Assert.Equal("OnResume", eventRecorder[0].CallerMemberName);
            Assert.Null(eventRecorder[0].Parameter);
        }
Пример #4
0
        public void CarouselPage()
        {
            var eventRecoder     = new EventRecorder();
            var contentPageMock1 = new ContentPageMock(eventRecoder)
            {
                Title = "contentPageMock1"
            };
            var contentPageMock2 = new ContentPageMock(eventRecoder)
            {
                Title = "contentPageMock2"
            };
            var viewModelMock    = new ViewModelMock(eventRecoder);
            var carouselPageMock = new CarouselPageMock(eventRecoder)
            {
                BindingContext = viewModelMock
            };

            carouselPageMock.Children.Add(contentPageMock1);
            carouselPageMock.Children.Add(contentPageMock2);

            LifecycleNoticeService.OnResume(new ApplicationMock {
                MainPage = carouselPageMock
            });

            Assert.Equal(4, eventRecoder.Count);

            Assert.NotNull(eventRecoder[0]);
            Assert.Equal(carouselPageMock, eventRecoder[0].Sender);
            Assert.Equal("OnResume", eventRecoder[0].CallerMemberName);
            Assert.Null(eventRecoder[0].Parameter);

            Assert.NotNull(eventRecoder[1]);
            Assert.Equal(viewModelMock, eventRecoder[1].Sender);
            Assert.Equal("OnResume", eventRecoder[1].CallerMemberName);
            Assert.Null(eventRecoder[1].Parameter);

            Assert.NotNull(eventRecoder[2]);
            Assert.Equal(contentPageMock1, eventRecoder[2].Sender);
            Assert.Equal("OnResume", eventRecoder[2].CallerMemberName);
            Assert.Null(eventRecoder[2].Parameter);

            Assert.NotNull(eventRecoder[3]);
            Assert.Equal(contentPageMock2, eventRecoder[3].Sender);
            Assert.Equal("OnResume", eventRecoder[3].CallerMemberName);
            Assert.Null(eventRecoder[3].Parameter);
        }
Пример #5
0
        public void MasterDetailPage()
        {
            var eventRecoder     = new EventRecorder();
            var contentPageMock1 = new ContentPageMock(eventRecoder)
            {
                Title = "contentPageMock1"
            };
            var contentPageMock2 = new ContentPageMock(eventRecoder)
            {
                Title = "contentPageMock2"
            };
            var viewModelMock        = new ViewModelMock(eventRecoder);
            var masterDetailPageMock = new MasterDetailPageMock(eventRecoder)
            {
                Master         = contentPageMock1,
                Detail         = contentPageMock2,
                BindingContext = viewModelMock
            };

            LifecycleNoticeService.OnResume(new ApplicationMock {
                MainPage = masterDetailPageMock
            });

            Assert.Equal(4, eventRecoder.Count);

            Assert.NotNull(eventRecoder[0]);
            Assert.Equal(masterDetailPageMock, eventRecoder[0].Sender);
            Assert.Equal("OnResume", eventRecoder[0].CallerMemberName);
            Assert.Null(eventRecoder[0].Parameter);

            Assert.NotNull(eventRecoder[1]);
            Assert.Equal(viewModelMock, eventRecoder[1].Sender);
            Assert.Equal("OnResume", eventRecoder[1].CallerMemberName);
            Assert.Null(eventRecoder[1].Parameter);

            Assert.NotNull(eventRecoder[2]);
            Assert.Equal(contentPageMock1, eventRecoder[2].Sender);
            Assert.Equal("OnResume", eventRecoder[2].CallerMemberName);
            Assert.Null(eventRecoder[2].Parameter);

            Assert.NotNull(eventRecoder[3]);
            Assert.Equal(contentPageMock2, eventRecoder[3].Sender);
            Assert.Equal("OnResume", eventRecoder[3].CallerMemberName);
            Assert.Null(eventRecoder[3].Parameter);
        }
Пример #6
0
        public void NavigationPage()
        {
            var eventRecoder       = new EventRecorder();
            var contentPageMock1   = new ContentPageMock(eventRecoder);
            var contentPageMock2   = new ContentPageMock(eventRecoder);
            var viewModelMock      = new ViewModelMock(eventRecoder);
            var navigationPageMock = new NavigationPageMock(contentPageMock1, eventRecoder)
            {
                BindingContext = viewModelMock
            };

            contentPageMock1.Navigation.PushAsync(contentPageMock2);

            LifecycleNoticeService.OnResume(new ApplicationMock {
                MainPage = navigationPageMock
            });

            Assert.Equal(4, eventRecoder.Count);

            Assert.NotNull(eventRecoder[0]);
            Assert.Equal(navigationPageMock, eventRecoder[0].Sender);
            Assert.Equal("OnResume", eventRecoder[0].CallerMemberName);
            Assert.Null(eventRecoder[0].Parameter);

            Assert.NotNull(eventRecoder[1]);
            Assert.Equal(viewModelMock, eventRecoder[1].Sender);
            Assert.Equal("OnResume", eventRecoder[1].CallerMemberName);
            Assert.Null(eventRecoder[1].Parameter);

            Assert.NotNull(eventRecoder[2]);
            Assert.Equal(contentPageMock1, eventRecoder[2].Sender);
            Assert.Equal("OnResume", eventRecoder[2].CallerMemberName);
            Assert.Null(eventRecoder[2].Parameter);

            Assert.NotNull(eventRecoder[3]);
            Assert.Equal(contentPageMock2, eventRecoder[3].Sender);
            Assert.Equal("OnResume", eventRecoder[3].CallerMemberName);
            Assert.Null(eventRecoder[3].Parameter);
        }
Пример #7
0
 protected override void OnResume()
 {
     LifecycleNoticeService.OnResume(this);
 }