Beispiel #1
0
        public void TestBindCommandUnauthorized()
        {
            var rootFrameNavigated         = false;
            var stubIRootNavigationService = new StubIRootNavigationService();

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

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

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

            var bindRequested       = false;
            var stubIStudentService = new StubIStudentService();

            stubIStudentService.BindAccountAsync(async studentId => {
                bindRequested = true;
                return(new ServiceResult
                {
                    Status = ServiceResultStatus.Unauthorized
                });
            });

            var bindingViewModel = new BindingViewModel(
                stubIRootNavigationService, stubIDialogService,
                stubIStudentService);

            bindingViewModel.BindCommand.Execute(null);

            Assert.IsFalse(rootFrameNavigated);
            Assert.IsFalse(dialogShown);
            Assert.IsTrue(bindRequested);
        }
Beispiel #2
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);
        }
Beispiel #3
0
        public void TestGetCommandUnauthorized()
        {
            var rootFrameNavigated         = false;
            var stubIRootNavigationService = new StubIRootNavigationService();

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

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

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

            var getRequested             = false;
            var stubIAnnouncementService = new StubIAnnouncementService();

            stubIAnnouncementService.GetAsync(async() => {
                getRequested = true;
                return(new ServiceResult <IEnumerable <Announcement> >
                {
                    Status = ServiceResultStatus.Unauthorized
                });
            });

            var announcementViewModel =
                new AnnouncementViewModel(stubIDialogService,
                                          stubIAnnouncementService, null);

            announcementViewModel.GetCommand.Execute(null);

            Assert.IsFalse(rootFrameNavigated);
            Assert.IsFalse(dialogShown);
            Assert.IsTrue(getRequested);
        }
Beispiel #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);
        }
Beispiel #5
0
        public void TestBindCommandSucceeded()
        {
            var studentIdToRequest = "Student ID";

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

            stubIRootNavigationService.Navigate(
                (sourcePageType, parameter, navigationTransition) =>
                rootFrameNavigated = sourcePageType == typeof(MyUvpPage) &&
                                     parameter == null &&
                                     navigationTransition ==
                                     NavigationTransition
                                     .EntranceNavigationTransition);

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

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

            var studentIdRequested  = "";
            var bindRequested       = false;
            var stubIStudentService = new StubIStudentService();

            stubIStudentService.BindAccountAsync(async studentId => {
                bindRequested      = true;
                studentIdRequested = studentId;
                return(new ServiceResult
                {
                    Status = ServiceResultStatus.NoContent
                });
            });

            var bindingViewModel = new BindingViewModel(
                stubIRootNavigationService, stubIDialogService,
                stubIStudentService);

            bindingViewModel.StudentId = studentIdToRequest;
            bindingViewModel.BindCommand.Execute(null);

            Assert.IsTrue(rootFrameNavigated);
            Assert.IsFalse(dialogShown);
            Assert.IsTrue(bindRequested);
            Assert.AreEqual(studentIdToRequest, studentIdRequested);
        }
Beispiel #6
0
        public void TestCheckCommandSucceeded()
        {
            var studentIdToRequest = "Student ID";

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

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

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

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

            var studentIdRequested  = "";
            var getRequested        = false;
            var stubIStudentService = new StubIStudentService();

            stubIStudentService.GetStudentByStudentIdAsync(async studentId => {
                getRequested       = true;
                studentIdRequested = studentId;
                return(new ServiceResult <Student> {
                    Status = ServiceResultStatus.OK,
                    Result = new Student {
                        StudentId = studentIdToRequest
                    }
                });
            });

            var bindingViewModel = new BindingViewModel(
                stubIRootNavigationService, stubIDialogService,
                stubIStudentService);

            bindingViewModel.StudentId = studentIdToRequest;
            bindingViewModel.CheckCommand.Execute(null);

            Assert.IsFalse(rootFrameNavigated);
            Assert.IsFalse(dialogShown);
            Assert.IsTrue(getRequested);
            Assert.AreEqual(studentIdToRequest, studentIdRequested);
            Assert.AreEqual(studentIdToRequest,
                            bindingViewModel.Student.StudentId);
        }
Beispiel #7
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);
        }
Beispiel #8
0
        public void TestBindCommandOther()
        {
            var messageToShow = "Error Message";

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

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

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

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

            var bindRequested       = false;
            var stubIStudentService = new StubIStudentService();

            stubIStudentService.BindAccountAsync(async studentId => {
                bindRequested = true;
                return(new ServiceResult {
                    Status = ServiceResultStatus.Exception,
                    Message = messageToShow
                });
            });

            var bindingViewModel = new BindingViewModel(
                stubIRootNavigationService, stubIDialogService,
                stubIStudentService);

            bindingViewModel.BindCommand.Execute(null);

            Assert.IsFalse(rootFrameNavigated);
            Assert.IsTrue(dialogShown);
            Assert.AreEqual(
                UvpClient.App.HttpClientErrorMessage + messageToShow,
                messageShown);
            Assert.IsTrue(bindRequested);
        }
Beispiel #9
0
        public void TestCheckCommandOther()
        {
            var messageToShow = "Error Message";

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

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

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

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

            var getRequested        = false;
            var announcementService = new StubIAnnouncementService();

            announcementService.GetAsync(async() => {
                getRequested = true;
                return(new ServiceResult <IEnumerable <Announcement> > {
                    Status = ServiceResultStatus.Exception,
                    Message = messageToShow
                });
            });

            var announcementViewModel =
                new AnnouncementViewModel(stubIDialogService,
                                          announcementService, null);

            announcementViewModel.GetCommand.Execute(null);

            Assert.IsFalse(rootFrameNavigated);
            Assert.IsTrue(dialogShown);
            Assert.AreEqual(
                UvpClient.App.HttpClientErrorMessage + messageToShow,
                messageShown);
            Assert.IsTrue(getRequested);
        }
Beispiel #10
0
        public void TestLoginCommandFailed()
        {
            var errorMessageToShow = "Error Message";

            var loginRequired        = false;
            var stubIIdentityService = new StubIIdentityService();

            stubIIdentityService.LoginAsync(async() => {
                loginRequired = true;
                return(new ServiceResult {
                    Status = ServiceResultStatus.BadRequest,
                    Message = errorMessageToShow
                });
            });

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

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


            var dialogShown        = false;
            var errorMessageShown  = "";
            var stubIDialogService = new StubIDialogService();

            stubIDialogService.ShowAsync(async message => {
                dialogShown       = true;
                errorMessageShown = message;
            });

            var loginViewModel = new LoginViewModel(stubIIdentityService,
                                                    stubIRootNavigationService, stubIDialogService);

            loginViewModel.LoginCommand.Execute(null);

            Assert.IsTrue(loginRequired);
            Assert.IsFalse(rootFrameNavigated);
            Assert.IsTrue(dialogShown);
            Assert.AreEqual(
                LoginViewModel.LoginErrorMessage + errorMessageToShow,
                errorMessageShown);
        }
Beispiel #11
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);
        }
Beispiel #12
0
        public void TestCheckCommandError()
        {
            var rootFrameNavigated         = false;
            var stubIRootNavigationService = new StubIRootNavigationService();

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

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

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

            var bindRequested       = false;
            var stubIStudentService = new StubIStudentService();

            stubIStudentService.GetStudentByStudentIdAsync(async studentId => {
                bindRequested = true;
                return(new ServiceResult <Student>
                {
                    Status = ServiceResultStatus.NotFound
                });
            });

            var bindingViewModel = new BindingViewModel(
                stubIRootNavigationService, stubIDialogService,
                stubIStudentService);

            bindingViewModel.CheckCommand.Execute(null);

            Assert.IsFalse(rootFrameNavigated);
            Assert.IsTrue(dialogShown);
            Assert.AreEqual(BindingViewModel.CheckNotFoundErrorMessage,
                            messageShown);
            Assert.IsTrue(bindRequested);
        }
Beispiel #13
0
        public void TestOpenCommand()
        {
            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 announcementViewModel =
                new AnnouncementViewModel(null, null,
                                          stubIRootNavigationService);

            announcementViewModel.OpenCommand.Execute(announcementToNavigate);

            Assert.IsTrue(rootFrameNavigated);
        }
Beispiel #14
0
        public void TestOpenStudentAssignmentCommand()
        {
            var studentAssignmentToNavigate = new StudentAssignment();

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

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

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

            myUvpViewModel.OpenStudentAssignmentCommand.Execute(
                studentAssignmentToNavigate);

            Assert.IsTrue(rootFrameNavigated);
        }
Beispiel #15
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);
        }
Beispiel #16
0
        public void TestGetCommandSucceeded()
        {
            var studentToReturn = new Student();

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

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

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

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

            var getMeRequested      = false;
            var stubIStudentService = new StubIStudentService();

            stubIStudentService.GetMeAsync(async() => {
                getMeRequested = true;
                return(new ServiceResult <Student>
                {
                    Status = ServiceResultStatus.OK, Result = studentToReturn
                });
            });

            var meViewModel =
                new MeViewModel(stubIStudentService, stubIDialogService);

            meViewModel.GetCommand.Execute(null);

            Assert.IsFalse(rootFrameNavigated);
            Assert.IsFalse(dialogShown);
            Assert.IsTrue(getMeRequested);
            Assert.AreSame(studentToReturn, meViewModel.Me);
        }
Beispiel #17
0
        public void TestLoginCommandSucceeded()
        {
            var loginRequired        = false;
            var stubIIdentityService = new StubIIdentityService();

            stubIIdentityService.LoginAsync(async() => {
                loginRequired = true;
                return(new ServiceResult {
                    Status = ServiceResultStatus.OK
                });
            });

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

            stubIRootNavigationService.Navigate(
                (sourcePageType, parameter, navigationTransition) =>
                rootFrameNavigated = sourcePageType == typeof(MyUvpPage) &&
                                     parameter == null &&
                                     navigationTransition ==
                                     NavigationTransition
                                     .EntranceNavigationTransition);

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

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

            var loginViewModel = new LoginViewModel(stubIIdentityService,
                                                    stubIRootNavigationService, stubIDialogService);

            loginViewModel.LoginCommand.Execute(null);

            Assert.IsTrue(loginRequired);
            Assert.IsTrue(rootFrameNavigated);
            Assert.IsFalse(dialogShown);
        }