public async Task AdminSectionShouldBeAvailableForAdminAfterLogin(bool userIsAdmin) { const string user = "******"; const string pass = "******"; Authentication.WhenUserIsKnown(user, pass, isAdmin: userIsAdmin); var vm = await GetSut(); var loginVm = NavigationAdapter.Should().BeDisplaying <LoginViewModel>(true).Which; loginVm.User = user; loginVm.Password = pass; loginVm.LoginCommand.Click(); NavigationAdapter.Should().NotBeDisplaying <LoginViewModel>(); NavigationAdapter.Should().BeDisplaying <MainPageViewModel>(); if (userIsAdmin) { vm.NavigateToAdminCommand.Should().BeEnabled(); } else { vm.NavigateToAdminCommand.Should().BeDisabled(); } }
public async Task CanLoginWithKnownUserAndPassword() { await LoginHappyPath(); Authentication.Should().BeLoggedIn(); NavigationAdapter.Should().NotBeDisplaying <LoginViewModel>(); }
public async Task CanChangePassword() { await RunHappyPath( o => CredentialService.PasswordChanged.Should().BeFalse()); CredentialService.PasswordChanged.Should().BeTrue(); NavigationAdapter.Should().NotBeDisplaying <PasswordChangeViewModel>(); }
public async Task LogoutLeadsToLogin() { Authentication.WhenUserIsLoggedIn(); (await GetSut()).LogoutCommand.Click(); Authentication.Should().NotBeLoggedIn(); NavigationAdapter.Should().BeDisplaying <LoginViewModel>(true); }
public async Task AdminCanNavigateToAdminOverview() { Authentication.WhenAdminIsLoggedIn(); var vm = await GetSut(); vm.IsAdmin.Should().BeTrue(); vm.NavigateToAdminCommand.Should().BeEnabled(); vm.NavigateToAdminCommand.Click(); NavigationAdapter.Should().BeDisplaying <OverviewViewModel>(); }
public async Task ShouldReturnToMainPageAfterLogin() { const string user = "******"; const string pass = "******"; Authentication.WhenUserIsKnown(user, pass); await GetSut(); var loginVm = NavigationAdapter.Should().BeDisplaying <LoginViewModel>(true).Which; loginVm.User = user; loginVm.Password = pass; loginVm.LoginCommand.Click(); NavigationAdapter.Should().NotBeDisplaying <LoginViewModel>(); NavigationAdapter.Should().BeDisplaying <MainPageViewModel>(); }
private async Task <LoginViewModel> LoginHappyPath(Action <HappyPathOptions> setup = null, Action <HappyPathOptions> beforeLogin = null) { var options = new HappyPathOptions(); setup?.Invoke(options); Authentication.WhenUserIsKnown(options.User, options.Pass, options.NeedsPasswordChange, options.IsAdmin); beforeLogin?.Invoke(options); var vm = await GetSut(); NavigationAdapter.Should().BeDisplaying <LoginViewModel>(); Login(vm, options.User, options.Pass); return(vm); }
private async Task <PasswordChangeViewModel> RunHappyPath(Action <HappyPathOptions> setup = null, Action <PasswordChangeViewModel> beforeSetFieldValues = null, Action <HappyPathOptions, PasswordChangeViewModel> beforeChangePassword = null) { var options = new HappyPathOptions(); setup?.Invoke(options); var vm = await GetSut(); NavigationAdapter.Should().BeDisplaying <PasswordChangeViewModel>(); beforeSetFieldValues?.Invoke(vm); vm.OldPassword = options.OldPassword; vm.NewPassword = options.NewPassword; vm.ConfirmNewPassword = options.ConfirmNewPassword; beforeChangePassword?.Invoke(options, vm); vm.ChangePasswordCommand.Click(); return(vm); }
public async Task CanRegisterNewUser() { var vm = await GetSut(); NavigationAdapter.Should().BeDisplaying <AddUserViewModel>(); vm.AddNewUserCommand.Should().BeDisabled(); vm.EmailAddress = "*****@*****.**"; vm.Firstname = "John"; vm.Lastname = "Doe"; vm.Password = "******"; vm.ConfirmPassword = vm.Password; vm.AddNewUserCommand.Should().BeEnabled(); vm.AddNewUserCommand.Click(); vm.AddNewUserCommand.Should().BeDisabled(); CredentialService.Should().HaveRegistered("John", "Doe"); NavigationAdapter.Should().NotBeDisplaying <AddUserViewModel>(); }
public async Task WhenNotLoggedInLoginViewGetsDisplayed() { await GetSut(); NavigationAdapter.Should().BeDisplaying <LoginViewModel>(true); }
public async Task DisplayPasswordChangeWhenPasswordShouldBeChangedAfterLogin() { await LoginHappyPath(setup : o => o.NeedsPasswordChange = true); NavigationAdapter.Should().BeDisplaying <PasswordChangeViewModel>(true); }