Esempio n. 1
0
        public void OnInitialize()
        {
            var eventRecorder   = new EventRecorder();
            var contentPageMock = new ContentPageMock(eventRecorder);
            var parameter       = new object();

            LifecycleNoticeService.OnInitialize(contentPageMock, parameter);

            Assert.Equal(1, eventRecorder.Count);
            Assert.Equal(contentPageMock, eventRecorder[0].Sender);
            Assert.Equal("OnInitialize", eventRecorder[0].CallerMemberName);
            Assert.Equal(parameter, eventRecorder[0].Parameter);
        }
Esempio n. 2
0
        public void NotNotifiedBindingContext()
        {
            var eventReporder = new EventRecorder();
            var contentPage   = new ContentPageMock(eventReporder)
            {
                BindingContext = new object()
            };

            LifecycleNoticeService.OnInitialize(contentPage);

            Assert.Equal(1, eventReporder.Count);
            Assert.Equal(contentPage, eventReporder[0].Sender);
            Assert.Equal("OnInitialize", eventReporder[0].CallerMemberName);
            Assert.Null(eventReporder[0].Parameter);
        }
Esempio n. 3
0
        public void NavigationPage()
        {
            var eventRecoder              = new EventRecorder();
            var contentPageMock1          = new ContentPageMock(eventRecoder);
            var contentPageMock2ViewModel = new ViewModelMock(eventRecoder);
            var contentPageMock2          = new ContentPageMock(eventRecoder)
            {
                BindingContext = contentPageMock2ViewModel
            };
            var viewModelMock      = new ViewModelMock(eventRecoder);
            var navigationPageMock = new NavigationPageMock(contentPageMock1, eventRecoder)
            {
                BindingContext = viewModelMock
            };

            contentPageMock1.Navigation.PushAsync(contentPageMock2);
            var parameter = "Hello, Parameter!";

            LifecycleNoticeService.OnInitialize(navigationPageMock, parameter);

            Assert.Equal(5, eventRecoder.Count);

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

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

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

            Assert.NotNull(eventRecoder[3]);
            Assert.Equal(contentPageMock2, eventRecoder[3].Sender);
            Assert.Equal("OnInitialize", eventRecoder[3].CallerMemberName);
            Assert.Equal(parameter, eventRecoder[3].Parameter);

            Assert.NotNull(eventRecoder[4]);
            Assert.Equal(contentPageMock2ViewModel, eventRecoder[4].Sender);
            Assert.Equal("OnInitialize", eventRecoder[4].CallerMemberName);
            Assert.Equal(parameter, eventRecoder[4].Parameter);
        }
Esempio n. 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);
            var parameter = "Hello, Parameter!";

            LifecycleNoticeService.OnInitialize(carouselPageMock, parameter);

            Assert.Equal(4, eventRecoder.Count);

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

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

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

            Assert.NotNull(eventRecoder[3]);
            Assert.Equal(contentPageMock2, eventRecoder[3].Sender);
            Assert.Equal("OnInitialize", eventRecoder[3].CallerMemberName);
            Assert.Equal(parameter, eventRecoder[3].Parameter);
        }
Esempio n. 5
0
        public void NestedPages()
        {
            var tabString     = new TabbedPageString();
            var tabNoParam    = new TabbedPageNotParameter();
            var tabObject     = new TabbedPageObject();
            var contentString = new ContentPageString();

            tabString.Children.Add(tabNoParam);
            tabNoParam.Children.Add(tabObject);
            tabObject.Children.Add(contentString);

            var parameter = "Hello, Parameter!";

            LifecycleNoticeService.OnInitialize(tabString, parameter);

            Assert.Equal(parameter, tabString.Parameter);
            Assert.False(tabNoParam.IsCalled);
            Assert.Equal(parameter, tabObject.Parameter);
            Assert.Equal(parameter, contentString.Parameter);
        }
Esempio n. 6
0
        public void ContentPage()
        {
            var eventRecoder    = new EventRecorder();
            var viewModelMock   = new ViewModelMock(eventRecoder);
            var contentPageMock = new ContentPageMock(eventRecoder)
            {
                BindingContext = viewModelMock
            };
            var parameter = "Hello, Parameter!";

            LifecycleNoticeService.OnInitialize(contentPageMock, parameter);

            Assert.Equal(2, eventRecoder.Count);

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

            Assert.NotNull(eventRecoder[1]);
            Assert.Equal(viewModelMock, eventRecoder[1].Sender);
            Assert.Equal("OnInitialize", eventRecoder[1].CallerMemberName);
            Assert.Equal(parameter, eventRecoder[1].Parameter);
        }