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); }
public void TestSignOutCommand() { var logoutRequest = false; var stubIIdentityService = new StubIIdentityService(); stubIIdentityService.SignOut(() => logoutRequest = true); var myUvpViewModel = new MyUvpViewModel(null, null, null, stubIIdentityService); myUvpViewModel.SignOutCommand.Execute(null); Assert.IsTrue(logoutRequest); }
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); }
public void TestLoginCommandSucceeded() { var loginRequired = false; var stubIIdentityService = new StubIIdentityService(); stubIIdentityService.LoginAsync(async() => { loginRequired = true; return(new ServiceResult { Status = ServiceResultStatus.OK }); }); 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 loginViewModel = new LoginViewModel(stubIIdentityService, stubIRootNavigationService, stubIDialogService); loginViewModel.LoginCommand.Execute(null); Assert.IsTrue(loginRequired); Assert.IsTrue(rootFrameNavigated); Assert.IsFalse(dialogShown); }