Ejemplo n.º 1
0
        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();
            }
        }
Ejemplo n.º 2
0
        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>();
        }
Ejemplo n.º 4
0
        public async Task LogoutLeadsToLogin()
        {
            Authentication.WhenUserIsLoggedIn();

            (await GetSut()).LogoutCommand.Click();

            Authentication.Should().NotBeLoggedIn();
            NavigationAdapter.Should().BeDisplaying <LoginViewModel>(true);
        }
Ejemplo n.º 5
0
        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>();
        }
Ejemplo n.º 6
0
        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>();
        }
Ejemplo n.º 7
0
        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>();
        }
Ejemplo n.º 10
0
        public async Task WhenNotLoggedInLoginViewGetsDisplayed()
        {
            await GetSut();

            NavigationAdapter.Should().BeDisplaying <LoginViewModel>(true);
        }
Ejemplo n.º 11
0
        public async Task DisplayPasswordChangeWhenPasswordShouldBeChangedAfterLogin()
        {
            await LoginHappyPath(setup : o => o.NeedsPasswordChange = true);

            NavigationAdapter.Should().BeDisplaying <PasswordChangeViewModel>(true);
        }