public void TestRefreshCommandSucceeded()
        {
            var studentAssignmentToReturn = new StudentAssignment();

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

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

            var refreshRequested    = false;
            var stubIStudentService = new StubIStudentAssignmentService();

            stubIStudentService.GetAsync(async id => {
                refreshRequested = true;
                return(new ServiceResult <StudentAssignment> {
                    Status = ServiceResultStatus.OK,
                    Result = studentAssignmentToReturn
                });
            });

            var studentAssignmentViewModel =
                new StudentAssignmentViewModel(stubIDialogService,
                                               stubIStudentService, null, null);

            studentAssignmentViewModel.RefreshCommand.Execute(null);

            Assert.IsFalse(dialogShown);
            Assert.IsTrue(refreshRequested);
            Assert.AreSame(studentAssignmentToReturn,
                           studentAssignmentViewModel.StudentAssignment);
        }
예제 #2
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 checkRequested      = false;
            var stubIStudentService = new StubIStudentService();

            stubIStudentService.GetMeAsync(async() => {
                checkRequested = true;
                return(new ServiceResult <Student>
                {
                    Status = ServiceResultStatus.Unauthorized
                });
            });

            var meViewModel =
                new MeViewModel(stubIStudentService, stubIDialogService);

            meViewModel.GetCommand.Execute(null);

            Assert.IsFalse(rootFrameNavigated);
            Assert.IsFalse(dialogShown);
            Assert.IsTrue(checkRequested);
        }
        public void TestSubmitCommandInvalidUrl()
        {
            var dialogShown        = false;
            var messageShown       = "";
            var stubIDialogService = new StubIDialogService();

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

            var studentAssignmentViewModel =
                new StudentAssignmentViewModel(stubIDialogService, null, null, null);

            studentAssignmentViewModel.StudentAssignment = new StudentAssignment {
                Solution = "not a url",
                Homework = new Homework {
                    Deadline = DateTime.MaxValue
                }
            };
            studentAssignmentViewModel.SubmitCommand.Execute(null);

            Assert.IsTrue(dialogShown);
            Assert.AreEqual(UvpClient.App.SolutionUrlErrorMessage,
                            messageShown);
        }
예제 #4
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 getRequested     = false;
            var stubMyUvpService = new StubIMyUvpService();

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

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

            myUvpViewModel.RefreshCommand.Execute(null);

            Assert.IsFalse(rootFrameNavigated);
            Assert.IsFalse(dialogShown);
            Assert.IsTrue(getRequested);
        }
예제 #5
0
        public void TestSubmitCommand()
        {
            var voteToSubmit = new Vote {
                Questionnaire =
                    new Questionnaire {
                    Deadline = DateTime.MaxValue
                },
                AnswerCollection = new List <QuestionnaireOption>
                {
                    new QuestionnaireOption()
                }
            };

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

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

            Vote voteSubmitted    = null;
            var  submitRequested  = false;
            var  stubIVoteService = new StubIVoteService();

            stubIVoteService.SubmitAsync(async vote => {
                submitRequested = true;
                voteSubmitted   = vote;
                return(new ServiceResult
                {
                    Status = ServiceResultStatus.NoContent
                });
            });

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

            stubIRootNavigationService.GoBack(() => backNavigated = true);

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

            stubITileService.ForceUpdate(() => updateRequested = true);

            var voteViewModel = new VoteViewModel(stubIDialogService,
                                                  stubIVoteService, stubIRootNavigationService, stubITileService);

            voteViewModel.Vote = voteToSubmit;
            voteViewModel.SubmitCommand.Execute(null);

            Assert.IsTrue(dialogShown);
            Assert.AreSame(VoteViewModel.AnswerSubmittedMessage, messageShown);
            Assert.IsTrue(submitRequested);
            Assert.AreSame(voteToSubmit, voteSubmitted);
            Assert.IsTrue(backNavigated);
            Assert.IsTrue(updateRequested);
        }
예제 #6
0
        public void TestSubmitCommand()
        {
            var groupAssignmentToSubmit = new GroupAssignment {
                HomeworkID = -1, Solution = "http://www.bing.com/",
                Homework   = new Homework {
                    Deadline = DateTime.MaxValue
                }
            };

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

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

            GroupAssignment groupAssignmentSubmitted    = null;
            var             submitRequested             = false;
            var             stubIGroupAssignmentService = new StubIGroupAssignmentService();

            stubIGroupAssignmentService.SubmitAsync(async groupAssignment => {
                submitRequested          = true;
                groupAssignmentSubmitted = groupAssignment;
                return(new ServiceResult
                {
                    Status = ServiceResultStatus.NoContent
                });
            });

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

            stubIRootNavigationService.GoBack(() => backNavigated = true);

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

            stubITileService.ForceUpdate(() => updateRequested = true);

            var groupAssignmentViewModel =
                new GroupAssignmentViewModel(stubIDialogService,
                                             stubIGroupAssignmentService, stubIRootNavigationService, stubITileService);

            groupAssignmentViewModel.GroupAssignment   = groupAssignmentToSubmit;
            groupAssignmentViewModel.GroupAssignmentId =
                groupAssignmentToSubmit.HomeworkID;
            groupAssignmentViewModel.SubmitCommand.Execute(null);

            Assert.IsTrue(dialogShown);
            Assert.AreSame(UvpClient.App.SolutionSubmittedMessage,
                           messageShown);
            Assert.IsTrue(submitRequested);
            Assert.AreSame(groupAssignmentToSubmit, groupAssignmentSubmitted);
            Assert.IsTrue(backNavigated);
            Assert.IsTrue(updateRequested);
        }
예제 #7
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);
        }
        public void TestSubmitCommandOther()
        {
            var studentAssignmentToSubmit = new StudentAssignment {
                HomeworkID = -1, Solution = "http://www.bing.com/",
                Homework   = new Homework {
                    Deadline = DateTime.MaxValue
                }
            };
            var messageToShow = "Error Message";

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

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

            StudentAssignment studentAssignmentSubmitted = null;
            var submitRequested = false;
            var stubIStudentAssignmentService =
                new StubIStudentAssignmentService();

            stubIStudentAssignmentService.SubmitAsync(async groupAssignment => {
                submitRequested = true;
                return(new ServiceResult {
                    Status = ServiceResultStatus.NotFound,
                    Message = messageToShow
                });
            });

            var studentAssignmentViewModel =
                new StudentAssignmentViewModel(stubIDialogService,
                                               stubIStudentAssignmentService, null, null);

            studentAssignmentViewModel.StudentAssignment =
                studentAssignmentToSubmit;
            studentAssignmentViewModel.StudentAssignmentId =
                studentAssignmentToSubmit.HomeworkID;
            studentAssignmentViewModel.SubmitCommand.Execute(null);

            Assert.IsTrue(dialogShown);
            Assert.AreEqual(
                UvpClient.App.HttpClientErrorMessage + messageToShow,
                messageShown);
            Assert.IsTrue(submitRequested);
        }
예제 #9
0
        public void TestSubmitCommandOther()
        {
            var voteToSubmit = new Vote {
                Questionnaire =
                    new Questionnaire {
                    Deadline = DateTime.MaxValue
                },
                AnswerCollection = new List <QuestionnaireOption>
                {
                    new QuestionnaireOption()
                }
            };
            var messageToShow = "Error Message";

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

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

            Vote voteSubmitted    = null;
            var  submitRequested  = false;
            var  stubIVoteService = new StubIVoteService();

            stubIVoteService.SubmitAsync(async vote => {
                submitRequested = true;
                return(new ServiceResult {
                    Status = ServiceResultStatus.NotFound,
                    Message = messageToShow
                });
            });

            var voteViewModel =
                new VoteViewModel(stubIDialogService, stubIVoteService, null, null);

            voteViewModel.Vote = voteToSubmit;
            voteViewModel.SubmitCommand.Execute(null);

            Assert.IsTrue(dialogShown);
            Assert.AreEqual(
                UvpClient.App.HttpClientErrorMessage + messageToShow,
                messageShown);
            Assert.IsTrue(submitRequested);
        }
        public void TestSubmitCommandOther()
        {
            var peerWorkGroupEvaluationToSubmit = new PeerWorkGroupEvaluation {
                Q1 = false, Q2 = 1, Q3 = 1, Q4 = 1, Q5 = 1, Q6 = 1, Q7 = 1,
                Q8 = false, Q9 = ""
            };
            var messageToShow = "Error Message";

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

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

            PeerWorkGroupEvaluation peerWorkGroupEvaluationSubmitted = null;
            var submitRequested = false;
            var stubIPeerWorkGroupEvaluationService =
                new StubIPeerWorkGroupEvaluationService();

            stubIPeerWorkGroupEvaluationService.SubmitAsync(
                async peerWorkGroupEvaluation => {
                submitRequested = true;
                peerWorkGroupEvaluationSubmitted = peerWorkGroupEvaluation;
                return(new ServiceResult {
                    Status = ServiceResultStatus.NotFound,
                    Message = messageToShow
                });
            });

            var peerWorkGroupEvaluationViewModel =
                new PeerWorkGroupEvaluationViewModel(stubIDialogService, null,
                                                     stubIPeerWorkGroupEvaluationService, null);

            peerWorkGroupEvaluationViewModel.PeerWorkGroupEvaluation =
                peerWorkGroupEvaluationToSubmit;
            peerWorkGroupEvaluationViewModel.SubmitCommand.Execute(null);

            Assert.IsTrue(dialogShown);
            Assert.AreEqual(
                UvpClient.App.HttpClientErrorMessage + messageToShow,
                messageShown);
            Assert.IsTrue(submitRequested);
        }
예제 #11
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);
        }
예제 #12
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);
        }
예제 #13
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);
        }
예제 #14
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);
        }
예제 #15
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);
        }
예제 #16
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);
        }
예제 #17
0
        public void TestGetCommandSucceeded()
        {
            var announcementToReturn = new List <Announcement>
            {
                new Announcement()
            };

            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.OK,
                    Result = announcementToReturn
                });
            });

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

            announcementViewModel.GetCommand.Execute(null);

            Assert.IsFalse(rootFrameNavigated);
            Assert.IsFalse(dialogShown);
            Assert.IsTrue(getRequested);
            Assert.AreSame(announcementToReturn,
                           announcementViewModel.Announcements);
        }
예제 #18
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);
        }
        public void TestSubmitCommandUnauthorized()
        {
            var peerWorkGroupEvaluationToSubmit = new PeerWorkGroupEvaluation {
                Q1 = false, Q2 = 1, Q3 = 1, Q4 = 1, Q5 = 1, Q6 = 1, Q7 = 1,
                Q8 = false, Q9 = ""
            };
            var messageToShow = "Error Message";

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

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

            var submitRequested = false;
            var stubIPeerWorkGroupEvaluationService =
                new StubIPeerWorkGroupEvaluationService();

            stubIPeerWorkGroupEvaluationService.SubmitAsync(
                async peerWorkGroupEvaluation => {
                submitRequested = true;
                return(new ServiceResult
                {
                    Status = ServiceResultStatus.Unauthorized
                });
            });

            var peerWorkGroupEvaluationViewModel =
                new PeerWorkGroupEvaluationViewModel(stubIDialogService, null,
                                                     stubIPeerWorkGroupEvaluationService, null);

            peerWorkGroupEvaluationViewModel.PeerWorkGroupEvaluation =
                peerWorkGroupEvaluationToSubmit;
            peerWorkGroupEvaluationViewModel.SubmitCommand.Execute(null);

            Assert.IsFalse(dialogShown);
            Assert.IsTrue(submitRequested);
        }
        public void TestSubmitCommandUnauthorized()
        {
            var studentAssignmentToSubmit = new StudentAssignment {
                HomeworkID = -1, Solution = "http://www.bing.com/",
                Homework   = new Homework {
                    Deadline = DateTime.MaxValue
                }
            };

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

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

            var submitRequested = false;
            var stubIStudentAssignmentService =
                new StubIStudentAssignmentService();

            stubIStudentAssignmentService.SubmitAsync(async groupAssignment => {
                submitRequested = true;
                return(new ServiceResult
                {
                    Status = ServiceResultStatus.Unauthorized
                });
            });

            var studentAssignmentViewModel =
                new StudentAssignmentViewModel(stubIDialogService,
                                               stubIStudentAssignmentService, null, null);

            studentAssignmentViewModel.StudentAssignment =
                studentAssignmentToSubmit;
            studentAssignmentViewModel.StudentAssignmentId =
                studentAssignmentToSubmit.HomeworkID;
            studentAssignmentViewModel.SubmitCommand.Execute(null);

            Assert.IsFalse(dialogShown);
            Assert.IsTrue(submitRequested);
        }
예제 #21
0
        public void TestSubmitCommandUnauthorized()
        {
            var voteToSubmit = new Vote {
                Questionnaire =
                    new Questionnaire {
                    Deadline = DateTime.MaxValue
                },
                AnswerCollection = new List <QuestionnaireOption>
                {
                    new QuestionnaireOption()
                }
            };

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

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

            var submitRequested  = false;
            var stubIVoteService = new StubIVoteService();

            stubIVoteService.SubmitAsync(async groupAssignment => {
                submitRequested = true;
                return(new ServiceResult
                {
                    Status = ServiceResultStatus.Unauthorized
                });
            });

            var voteViewModel =
                new VoteViewModel(stubIDialogService, stubIVoteService, null, null);

            voteViewModel.Vote = voteToSubmit;
            voteViewModel.SubmitCommand.Execute(null);

            Assert.IsFalse(dialogShown);
            Assert.IsTrue(submitRequested);
        }
        public void TestRefreshCommandOther()
        {
            var messageToShow = "Error Message";

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

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

            var refreshRequested = false;
            var stubIStudentAssignmentService =
                new StubIStudentAssignmentService();

            stubIStudentAssignmentService.GetAsync(async id => {
                refreshRequested = true;
                return(new ServiceResult <StudentAssignment> {
                    Status = ServiceResultStatus.Exception,
                    Message = messageToShow
                });
            });

            var studentAssignmentViewModel =
                new StudentAssignmentViewModel(stubIDialogService,
                                               stubIStudentAssignmentService, null, null);

            studentAssignmentViewModel.RefreshCommand.Execute(null);

            Assert.IsTrue(dialogShown);
            Assert.AreEqual(
                UvpClient.App.HttpClientErrorMessage + messageToShow,
                messageShown);
            Assert.IsTrue(refreshRequested);
        }
예제 #23
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);
        }
예제 #24
0
        public void TestRefreshCommandSucceeded()
        {
            var myUvpToReturn = new MyUvp();

            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 myUvpService   = new StubIMyUvpService();

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

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

            myUvpViewModel.RefreshCommand.Execute(null);

            Assert.IsFalse(rootFrameNavigated);
            Assert.IsFalse(dialogShown);
            Assert.IsTrue(checkRequested);
            Assert.AreSame(myUvpToReturn, myUvpViewModel.MyUvp);
        }
예제 #25
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);
        }
예제 #26
0
        public void TestGetCommandOther()
        {
            var messageToShow = "Error Message";

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

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

            var getMeRequested          = false;
            var stubIPrivacyDataService = new StubIPrivacyDataService();

            stubIPrivacyDataService.GetAsync(async() => {
                getMeRequested = true;
                return(new ServiceResult <PrivacyData> {
                    Status = ServiceResultStatus.Exception,
                    Message = messageToShow
                });
            });

            var privacyDataViewModel =
                new PrivacyDataViewModel(stubIDialogService,
                                         stubIPrivacyDataService);

            privacyDataViewModel.GetCommand.Execute(null);

            Assert.IsTrue(dialogShown);
            Assert.AreEqual(
                UvpClient.App.HttpClientErrorMessage + messageToShow,
                messageShown);
            Assert.IsTrue(getMeRequested);
        }
예제 #27
0
        public void TestOpenCommandOther()
        {
            var messageToShow = "Error Message";

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

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

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

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

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

            announcementViewModel.GetCommand.Execute(null);

            Assert.IsTrue(dialogShown);
            Assert.AreEqual(
                UvpClient.App.HttpClientErrorMessage + messageToShow,
                messageShown);
            Assert.IsTrue(getRequested);
        }
        public void TestSubmitCommand()
        {
            var peerWorkGroupEvaluationToSubmit = new PeerWorkGroupEvaluation {
                Q1 = false, Q2 = 1, Q3 = 1, Q4 = 1, Q5 = 1, Q6 = 1, Q7 = 1,
                Q8 = false, Q9 = ""
            };
            var messageToShow = "Error Message";

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

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

            PeerWorkGroupEvaluation peerWorkGroupEvaluationSubmitted = null;
            var submitRequested = false;
            var stubIPeerWorkGroupEvaluationService =
                new StubIPeerWorkGroupEvaluationService();

            stubIPeerWorkGroupEvaluationService.SubmitAsync(
                async peerWorkGroupEvaluation => {
                submitRequested = true;
                peerWorkGroupEvaluationSubmitted = peerWorkGroupEvaluation;
                return(new ServiceResult
                {
                    Status = ServiceResultStatus.NoContent
                });
            });

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

            stubIRootNavigationService.GoBack(() => backNavigated = true);

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

            stubITileService.ForceUpdate(() => updateRequested = true);

            var peerWorkGroupEvaluationViewModel =
                new PeerWorkGroupEvaluationViewModel(stubIDialogService,
                                                     stubIRootNavigationService,
                                                     stubIPeerWorkGroupEvaluationService, stubITileService);

            peerWorkGroupEvaluationViewModel.PeerWorkGroupEvaluation =
                peerWorkGroupEvaluationToSubmit;
            peerWorkGroupEvaluationViewModel.SubmitCommand.Execute(null);

            Assert.IsTrue(dialogShown);
            Assert.AreSame(
                PeerWorkGroupEvaluationViewModel
                .PeerWorkGroupEvaluationSubmittedMessage, messageShown);
            Assert.IsTrue(submitRequested);
            Assert.AreSame(peerWorkGroupEvaluationToSubmit,
                           peerWorkGroupEvaluationSubmitted);
            Assert.IsTrue(backNavigated);
            Assert.IsTrue(updateRequested);
        }