예제 #1
0
        public void TestRefreshCommandUnauthorized()
        {
            var rootFrameNavigated        = false;
            var stubRootNavigationService = new StubIRootNavigationService();

            stubRootNavigationService.Navigate(
                (sourcePageType, parameter, navigationTransition) =>
                rootFrameNavigated = true);

            var dialogShown       = false;
            var stubDialogService = new StubIDialogService();

            stubDialogService.ShowAsync(async message => dialogShown = true);

            var checkRequested   = false;
            var stubMyUvpService = new StubIMyUvpService();

            stubMyUvpService.GetAsync(async() => {
                checkRequested = true;
                return(new ServiceResult <MyUvp>
                {
                    Status = ServiceResultStatus.Unauthorized
                });
            });

            var myUvpViewModel = new MyUvpViewModel(stubMyUvpService,
                                                    stubDialogService, stubRootNavigationService, null);

            myUvpViewModel.RefreshCommand.Execute(null);

            Assert.IsFalse(rootFrameNavigated);
            Assert.IsFalse(dialogShown);
            Assert.IsTrue(checkRequested);
        }
예제 #2
0
        public void TestSignOutCommand()
        {
            var logoutRequest        = false;
            var stubIIdentityService = new StubIIdentityService();

            stubIIdentityService.SignOutAsync(async() => {
                logoutRequest = true;
                return(new ServiceResult
                {
                    Status = ServiceResultStatus.NoContent
                });
            });

            var resetRequest     = false;
            var stubITileService = new StubITileService();

            stubITileService.Reset(() => resetRequest = true);

            var myUvpViewModel = new MyUvpViewModel(null, null, null,
                                                    stubIIdentityService, stubITileService);

            myUvpViewModel.SignOutCommand.Execute(null);

            Assert.IsTrue(logoutRequest);
            Assert.IsTrue(resetRequest);
        }
예제 #3
0
        public void TestSignOutCommand()
        {
            var logoutRequest        = false;
            var stubIIdentityService = new StubIIdentityService();

            stubIIdentityService.SignOut(() => logoutRequest = true);

            var myUvpViewModel = new MyUvpViewModel(null, null, null, stubIIdentityService);

            myUvpViewModel.SignOutCommand.Execute(null);

            Assert.IsTrue(logoutRequest);
        }
예제 #4
0
        public void TestRefreshCommandSucceeded()
        {
            var myUvpToReturn = new MyUvp
            {
                Me = new Student {
                    StudentId = "stuid"
                }
            };

            var rootFrameNavigated        = false;
            var stubRootNavigationService = new StubIRootNavigationService();

            stubRootNavigationService.Navigate(
                (sourcePageType, parameter, navigationTransition) =>
                rootFrameNavigated = true);

            var dialogShown       = false;
            var stubDialogService = new StubIDialogService();

            stubDialogService.ShowAsync(async message => dialogShown = true);

            var getRequested = false;
            var myUvpService = new StubIMyUvpService();

            myUvpService.GetAsync(async() => {
                getRequested = true;
                return(new ServiceResult <MyUvp>
                {
                    Status = ServiceResultStatus.OK, Result = myUvpToReturn
                });
            });

            var stubITileService = new StubITileService();
            var studentIdSet     = "";

            stubITileService.SetUpdate(studentId => studentIdSet = studentId);

            var myUvpViewModel = new MyUvpViewModel(myUvpService,
                                                    stubDialogService, stubRootNavigationService, null,
                                                    stubITileService);

            myUvpViewModel.RefreshCommand.Execute(null);

            Assert.IsFalse(rootFrameNavigated);
            Assert.IsFalse(dialogShown);
            Assert.IsTrue(getRequested);
            Assert.AreSame(myUvpToReturn, myUvpViewModel.MyUvp);
            Assert.AreEqual(myUvpToReturn.Me.StudentId, studentIdSet);
        }
예제 #5
0
        public void TestOpenPrivacyDataCommand()
        {
            var rootFrameNavigated         = false;
            var stubIRootNavigationService = new StubIRootNavigationService();

            stubIRootNavigationService.Navigate((type, parameter, transition) =>
                                                rootFrameNavigated = type == typeof(PrivacyDataPage) &&
                                                                     parameter == null &&
                                                                     transition == NavigationTransition
                                                                     .DrillInNavigationTransition);

            var myUvpViewModel = new MyUvpViewModel(null, null,
                                                    stubIRootNavigationService, null);

            myUvpViewModel.OpenPrivacyDataCommand.Execute(null);

            Assert.IsTrue(rootFrameNavigated);
        }
예제 #6
0
        public void TestCheckCommandOther()
        {
            var messageToShow = "Error Message";

            var rootFrameNavigated        = false;
            var stubRootNavigationService = new StubIRootNavigationService();

            stubRootNavigationService.Navigate(
                (sourcePageType, parameter, navigationTransition) =>
                rootFrameNavigated = true);

            var messageShown      = "";
            var dialogShown       = false;
            var stubDialogService = new StubIDialogService();

            stubDialogService.ShowAsync(async message => {
                dialogShown  = true;
                messageShown = message;
            });

            var bindRequested = false;
            var myUvpService  = new StubIMyUvpService();

            myUvpService.GetAsync(async() => {
                bindRequested = true;
                return(new ServiceResult <MyUvp> {
                    Status = ServiceResultStatus.Exception,
                    Message = messageToShow
                });
            });

            var myUvpViewModel = new MyUvpViewModel(myUvpService,
                                                    stubDialogService, stubRootNavigationService, null);

            myUvpViewModel.RefreshCommand.Execute(null);

            Assert.IsFalse(rootFrameNavigated);
            Assert.IsTrue(dialogShown);
            Assert.AreEqual(
                UvpClient.App.HttpClientErrorMessage + messageToShow,
                messageShown);
            Assert.IsTrue(bindRequested);
        }
예제 #7
0
        public void TestOpenAnnouncementCommand()
        {
            var announcementToNavigate = new Announcement();

            var rootFrameNavigated         = false;
            var stubIRootNavigationService = new StubIRootNavigationService();

            stubIRootNavigationService.Navigate((type, parameter, transition) =>
                                                rootFrameNavigated = type == typeof(AnnouncementPage) &&
                                                                     parameter == announcementToNavigate &&
                                                                     transition == NavigationTransition
                                                                     .DrillInNavigationTransition);

            var myUvpViewModel = new MyUvpViewModel(null, null,
                                                    stubIRootNavigationService, null);

            myUvpViewModel.OpenAnnouncementCommand.Execute(
                announcementToNavigate);

            Assert.IsTrue(rootFrameNavigated);
        }
예제 #8
0
        public void TestOpenPeerWorkGroupEvaluationCommand()
        {
            var peerWorkGroupEvaluationToNavigate =
                new PeerWorkGroupEvaluation();

            var rootFrameNavigated         = false;
            var stubIRootNavigationService = new StubIRootNavigationService();

            stubIRootNavigationService.Navigate((type, parameter, transition) =>
                                                rootFrameNavigated =
                                                    type == typeof(PeerWorkGroupEvaluationPage) &&
                                                    parameter == peerWorkGroupEvaluationToNavigate &&
                                                    transition == NavigationTransition
                                                    .DrillInNavigationTransition);

            var myUvpViewModel = new MyUvpViewModel(null, null,
                                                    stubIRootNavigationService, null);

            myUvpViewModel.OpenPeerWorkGroupEvaluationCommand.Execute(
                peerWorkGroupEvaluationToNavigate);

            Assert.IsTrue(rootFrameNavigated);
        }