コード例 #1
0
        public void ContentPage()
        {
            var eventRecoder    = new EventRecorder();
            var viewModelMock   = new ViewModelMock(eventRecoder);
            var contentPageMock = new ContentPageMock(eventRecoder)
            {
                BindingContext = viewModelMock
            };

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

            Assert.Equal(2, eventRecoder.Count);

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

            Assert.NotNull(eventRecoder[1]);
            Assert.Equal(contentPageMock, eventRecoder[1].Sender);
            Assert.Equal("OnSleep", eventRecoder[1].CallerMemberName);
            Assert.Null(eventRecoder[1].Parameter);
        }
コード例 #2
0
        public void OnSleep_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.OnSleep(application);

            Assert.Equal(3, eventRecorder.Count);

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

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

            Assert.Equal(contentPageMock1, eventRecorder[2].Sender);
            Assert.Equal("OnSleep", eventRecorder[2].CallerMemberName);
            Assert.Null(eventRecorder[2].Parameter);
        }
コード例 #3
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.OnSleep(new ApplicationMock {
                MainPage = carouselPageMock
            });

            Assert.Equal(4, eventRecoder.Count);

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

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

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

            Assert.NotNull(eventRecoder[3]);
            Assert.Equal(carouselPageMock, eventRecoder[3].Sender);
            Assert.Equal("OnSleep", eventRecoder[3].CallerMemberName);
            Assert.Null(eventRecoder[3].Parameter);
        }
コード例 #4
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.OnSleep(new ApplicationMock {
                MainPage = masterDetailPageMock
            });

            Assert.Equal(4, eventRecoder.Count);

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

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

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

            Assert.NotNull(eventRecoder[3]);
            Assert.Equal(masterDetailPageMock, eventRecoder[3].Sender);
            Assert.Equal("OnSleep", eventRecoder[3].CallerMemberName);
            Assert.Null(eventRecoder[3].Parameter);
        }
コード例 #5
0
        public void OnSleep()
        {
            lock (ApplicationServiceFixture.ApplicationMock)
            {
                var eventRecorder   = new EventRecorder();
                var contentPageMock = new ContentPageMock(eventRecorder);

                var application = new ApplicationMock {
                    MainPage = contentPageMock
                };

                LifecycleNoticeService.OnSleep(application);

                Assert.Equal(1, eventRecorder.Count);
                Assert.Equal(contentPageMock, eventRecorder[0].Sender);
                Assert.Equal("OnSleep", eventRecorder[0].CallerMemberName);
                Assert.Null(eventRecorder[0].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.OnSleep(new ApplicationMock {
                MainPage = navigationPageMock
            });

            Assert.Equal(4, eventRecoder.Count);

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

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

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

            Assert.NotNull(eventRecoder[3]);
            Assert.Equal(navigationPageMock, eventRecoder[3].Sender);
            Assert.Equal("OnSleep", eventRecoder[3].CallerMemberName);
            Assert.Null(eventRecoder[3].Parameter);
        }
コード例 #7
0
 protected override void OnSleep()
 {
     LifecycleNoticeService.OnSleep(this);
 }