Esempio n. 1
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);
        }
Esempio 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);
        }
        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);
        }