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); }
public void TestGetCommandUnauthorized() { 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.Unauthorized }); }); var meViewModel = new MeViewModel(stubIStudentService, stubIDialogService); meViewModel.GetCommand.Execute(null); Assert.IsFalse(dialogShown); Assert.IsTrue(getMeRequested); }
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); }
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 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); }
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); }
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 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 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); }