Esempio n. 1
0
        public async Task WhenUsernameDoesNotExist_ItShouldDoNothing()
        {
            var command = new RequestPasswordResetCommand(null, ValidUsername.Parse(Username));

            this.userManager.Setup(_ => _.FindByNameAsync(Username)).ReturnsAsync(null);

            await this.target.HandleAsync(command);
        }
Esempio n. 2
0
        public async Task WhenUsernameExists_ItShouldSendEmail()
        {
            var command = new RequestPasswordResetCommand(null, ValidUsername.Parse(Username));

            this.userManager.Setup(_ => _.FindByNameAsync(Username)).ReturnsAsync(new FifthweekUser()
            {
                Id       = UserId,
                UserName = Username
            });

            await this.AssertEmailSent(command);
        }
Esempio n. 3
0
        public async Task WhenPostingUserRegistration_ItShouldIssueRegisterUserCommand()
        {
            var registration = NewRegistrationData();

            var command = new RegisterUserCommand(
                UserId,
                registration.ExampleWork,
                ValidEmail.Parse(registration.Email),
                ValidUsername.Parse(registration.Username),
                ValidPassword.Parse(registration.Password),
                false);

            this.guidCreator.Setup(_ => _.CreateSqlSequential()).Returns(UserId.Value);
            this.registerUser.Setup(v => v.HandleAsync(command)).Returns(Task.FromResult(0));

            var result = await this.controller.PostRegistrationAsync(registration);

            Assert.IsInstanceOfType(result, typeof(OkResult));
            this.registerUser.Verify(v => v.HandleAsync(command));
            this.guidCreator.Verify(v => v.CreateSqlSequential());
        }
 public void AssertAvailableShouldReturnForNonReservedUsernames()
 {
     this.target.AssertNotReserved(ValidUsername.Parse("phil"));
 }
 public void AssertAvailableShouldThrowAnExceptionForReservedUsernames()
 {
     this.target.AssertNotReserved(ValidUsername.Parse("static"));
 }
 public void IsReservedShouldReturnFalseForNonReservedUsernames()
 {
     Assert.IsFalse(this.target.IsReserved(ValidUsername.Parse("phil")));
     Assert.IsFalse(this.target.IsReserved(ValidUsername.Parse("fifthweek")));
 }
 public void IsReservedShouldReturnTrueForReservedUsernames()
 {
     Assert.IsTrue(this.target.IsReserved(ValidUsername.Parse("static")));
     Assert.IsTrue(this.target.IsReserved(ValidUsername.Parse("bower_components")));
 }
Esempio n. 8
0
 public static RequestPasswordResetCommand NewCommand(PasswordResetRequestData data)
 {
     return(new RequestPasswordResetCommand(
                data.Email == null ? null : ValidEmail.Parse(data.Email),
                data.Username == null ? null : ValidUsername.Parse(data.Username)));
 }
Esempio n. 9
0
        public async Task WhenEmailExistsAndUsernameExists_ItShouldSendEmailToUserIdentifiedByUsername()
        {
            var command = new RequestPasswordResetCommand(ValidEmail.Parse(EmailAddress), ValidUsername.Parse(Username));

            this.userManager.Setup(_ => _.FindByNameAsync(Username)).ReturnsAsync(new FifthweekUser()
            {
                Id       = UserId,
                UserName = Username
            });
            this.userManager.Setup(_ => _.FindByEmailAsync(EmailAddress)).ReturnsAsync(new FifthweekUser()
            {
                Id       = UserId2,
                UserName = Username
            });

            await this.AssertEmailSent(command);
        }