public void TestGetCommandSucceeded()
        {
            var privacyDataToReturn = new PrivacyData();

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

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

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

            stubIPrivacyDataService.GetAsync(async() => {
                getRequested = true;
                return(new ServiceResult <PrivacyData> {
                    Status = ServiceResultStatus.OK,
                    Result = privacyDataToReturn
                });
            });

            var privacyDataViewModel =
                new PrivacyDataViewModel(stubIDialogService,
                                         stubIPrivacyDataService);

            privacyDataViewModel.GetCommand.Execute(null);

            Assert.IsFalse(dialogShown);
            Assert.IsTrue(getRequested);
            Assert.AreSame(privacyDataToReturn,
                           privacyDataViewModel.PrivacyData);
        }
        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);
        }
Exemple #3
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);
        }
        public void TestGetCommandUnauthorized()
        {
            var dialogShown        = false;
            var stubIDialogService = new StubIDialogService();

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

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

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

            var privacyDataViewModel =
                new PrivacyDataViewModel(stubIDialogService,
                                         stubIPrivacyDataService);

            privacyDataViewModel.GetCommand.Execute(null);

            Assert.IsFalse(dialogShown);
            Assert.IsTrue(getMeRequested);
        }
Exemple #5
0
        public void TestOpenCommandSucceeded()
        {
            var announcementToReturn = new List <Announcement>
            {
                new Announcement()
            };
            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(dialogShown);
            Assert.IsTrue(getRequested);
            Assert.AreSame(announcementToReturn,
                           announcementViewModel.Announcements);
        }
Exemple #6
0
        public void TestGetCommandSucceeded()
        {
            var studentToReturn = new Student();

            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(dialogShown);
            Assert.IsTrue(getMeRequested);
            Assert.AreSame(studentToReturn, meViewModel.Me);
        }
Exemple #7
0
        public void TestRefreshCommandSucceeded()
        {
            var groupAssignmentToReturn = new GroupAssignment
            {
                Solution = "http://www.163.com/"
            };

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

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

            var refreshRequested            = false;
            var stubIGroupAssignmentService = new StubIGroupAssignmentService();

            stubIGroupAssignmentService.GetAsync(async id => {
                refreshRequested = true;
                return(new ServiceResult <GroupAssignment> {
                    Status = ServiceResultStatus.OK,
                    Result = groupAssignmentToReturn
                });
            });

            var groupAssignmentViewModel =
                new GroupAssignmentViewModel(stubIDialogService,
                                             stubIGroupAssignmentService, null, null);

            groupAssignmentViewModel.RefreshCommand.Execute(null);

            Assert.IsFalse(dialogShown);
            Assert.IsTrue(refreshRequested);
            Assert.AreSame(groupAssignmentToReturn,
                           groupAssignmentViewModel.GroupAssignment);
        }
Exemple #8
0
        public void TestSubmitCommandEmptyCollection()
        {
            var voteToSubmit = new Vote {
                Questionnaire = new Questionnaire {
                    Deadline = DateTime.MaxValue
                }
            };

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

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

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

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

            Assert.IsTrue(dialogShown);
            Assert.AreEqual(VoteViewModel.AnswerCollectionEmptyErrorMessage,
                            messageShown);
        }
Exemple #9
0
        public void TestSubmitCommandInvalidUrl()
        {
            var dialogShown        = false;
            var messageShown       = "";
            var stubIDialogService = new StubIDialogService();

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

            var groupAssignmentViewModel =
                new GroupAssignmentViewModel(stubIDialogService, null, null, null);

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

            Assert.IsTrue(dialogShown);
            Assert.AreEqual(UvpClient.App.SolutionUrlErrorMessage,
                            messageShown);
        }
Exemple #10
0
        public void TestRefreshCommandUnauthorized()
        {
            var dialogShown        = false;
            var stubIDialogService = new StubIDialogService();

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

            var refreshRequested            = false;
            var stubIGroupAssignmentService = new StubIGroupAssignmentService();

            stubIGroupAssignmentService.GetAsync(async id => {
                refreshRequested = true;
                return(new ServiceResult <GroupAssignment>
                {
                    Status = ServiceResultStatus.Unauthorized
                });
            });

            var groupAssignmentViewModel =
                new GroupAssignmentViewModel(stubIDialogService,
                                             stubIGroupAssignmentService, null, null);

            groupAssignmentViewModel.RefreshCommand.Execute(null);

            Assert.IsFalse(dialogShown);
            Assert.IsTrue(refreshRequested);
        }
Exemple #11
0
        public void TestOpenCommandUnauthorized()
        {
            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(dialogShown);
            Assert.IsTrue(getRequested);
        }
Exemple #12
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 stubIStudentService = new StubIStudentService();

            stubIStudentService.GetMeAsync(async() => {
                getMeRequested = true;
                return(new ServiceResult <Student> {
                    Status = ServiceResultStatus.Exception,
                    Message = messageToShow
                });
            });

            var meViewModel =
                new MeViewModel(stubIStudentService, stubIDialogService);

            meViewModel.GetCommand.Execute(null);

            Assert.IsTrue(dialogShown);
            Assert.AreEqual(
                UvpClient.App.HttpClientErrorMessage + messageToShow,
                messageShown);
            Assert.IsTrue(getMeRequested);
        }
Exemple #13
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);
        }
Exemple #14
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);
        }
Exemple #15
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);
        }
Exemple #16
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);
        }
        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);
        }
Exemple #19
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);
        }
Exemple #21
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);
        }
Exemple #22
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);
        }
Exemple #23
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);
        }
Exemple #24
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);
        }
        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);
        }
        private UsersViewModel CreateUsersViewModel()
        {
            var stubUserRepository = new StubIUserRepository();
            stubUserRepository.GetUsersAsync = () => 
            {
                var users = new ObservableCollection<Model.User>();
                return Task.FromResult(users);
            };

            var stubResourceService = new StubIResourceService();
            stubResourceService.GetStringString = (_) =>
            {
                return string.Empty;
            };

            var stubDialogService = new StubIDialogService();

            return new UsersViewModel(stubUserRepository, stubResourceService, stubDialogService);
        }
Exemple #27
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);
        }
Exemple #28
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);
        }
Exemple #31
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);
        }