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);
        }
        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);
        }
        public void TestSubmitCommand()
        {
            var studentAssignmentToSubmit = new StudentAssignment {
                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;
            });

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

            stubIStudentAssignmentService.SubmitAsync(async groupAssignment => {
                submitRequested            = true;
                studentAssignmentSubmitted = 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 studentAssignmentViewModel = new StudentAssignmentViewModel(
                stubIDialogService, stubIStudentAssignmentService,
                stubIRootNavigationService, stubITileService);

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

            Assert.IsTrue(dialogShown);
            Assert.AreSame(UvpClient.App.SolutionSubmittedMessage,
                           messageShown);
            Assert.IsTrue(submitRequested);
            Assert.AreSame(studentAssignmentToSubmit,
                           studentAssignmentSubmitted);
            Assert.IsTrue(backNavigated);
            Assert.IsTrue(updateRequested);
        }