Beispiel #1
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);
        }
        //[SetUp]
        public virtual void TestInitialize()
        {
            WriteLine("=>Test: TestInitialize");
            if (Application.Current == null)
            {
                WriteLine("=>Test: Create new Application");
                new Thread(delegate() {
                    var app = new ApplicationMock {
                        ShutdownMode = ShutdownMode.OnExplicitShutdown,
                        //Resources = ???,
                        //MainWindow = new MainWindowMock()
                    };
                    Dispatcher.Run();
                    app.Run();
                    // now Application.Current is valid;
                })
                {
                    IsBackground = true
                }.Start();
            }
            else
            {
                WriteLine("=>Test: Using existing Application");
            }

            //Wait until Application.Current is valid
            while (Application.Current == null)
            {
                Thread.Sleep(25);
            }
        }
        public void ApplicationAdapter_ModalPopped()
        {
            var mock    = new ApplicationMock();
            var adapter = (ApplicationService.IApplication) new ApplicationService.ApplicationAdapter(mock);
            var page1   = new ContentPage();

            adapter.MainPage = page1;

            var page2 = new ContentPage();

            page1.Navigation.PushModalAsync(page2);

            bool popped = false;

            adapter.ModalPopped += (sender, args) =>
            {
                popped = true;
                Assert.NotNull(sender);
                Assert.NotNull(args);
                Assert.Equal(page2, args.Modal);
            };

            page2.Navigation.PopModalAsync();

            Assert.True(popped);
        }
Beispiel #4
0
 [Given(@"A new application")] public void GivenANewApplication()
 {
     App = new ApplicationMock(
         "testApp",
         Client = new ClientProxyMock(),
         NullLogger <Application> .Instance
         );
 }
        public void ApplicationAdapter_MainPage()
        {
            var mock    = new ApplicationMock();
            var adapter = (ApplicationService.IApplication) new ApplicationService.ApplicationAdapter(mock);
            var page    = new ContentPage();

            adapter.MainPage = page;

            Assert.Equal(page, mock.MainPage);
            Assert.Equal(page, adapter.MainPage);
        }
Beispiel #6
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);
        }
        public void ApplicationAdapter_ModalPopped_WhenNotListened()
        {
            var mock    = new ApplicationMock();
            var adapter = (ApplicationService.IApplication) new ApplicationService.ApplicationAdapter(mock);
            var page1   = new ContentPage();

            adapter.MainPage = page1;

            var page2 = new ContentPage();

            page1.Navigation.PushModalAsync(page2);

            page2.Navigation.PopModalAsync();

            Assert.True(true);
        }
Beispiel #8
0
        public void ApplicationIsNotNull()
        {
            var app = new ApplicationMock();

            Assert.NotNull(app);
        }