Ejemplo n.º 1
0
        public void TestSignOutCommand()
        {
            var logoutRequest        = false;
            var stubIIdentityService = new StubIIdentityService();

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

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

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

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

            myUvpViewModel.SignOutCommand.Execute(null);

            Assert.IsTrue(logoutRequest);
            Assert.IsTrue(resetRequest);
        }
Ejemplo n.º 2
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);
        }
Ejemplo n.º 3
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);
        }
Ejemplo n.º 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);
        }
        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);
        }