Esempio n. 1
0
        public async Task ShouldRequireUniqueEmail()
        {
            var preexistingEmployee = await Register();

            var password = SamplePassword();
            var command  = new RegisterEmployee.Command
            {
                Email           = SampleEmail(),
                Password        = password,
                ConfirmPassword = password,
                FirstName       = "John",
                LastName        = "Smith",
                Title           = "Junior Consultant",
                Office          = Office.Houston,
                PhoneNumber     = "555-123-9999"
            };

            command.ShouldValidate();

            command.Email = preexistingEmployee.Email;

            command.ShouldNotValidate(
                $"Another employee already uses '{command.Email}'. " +
                "Please enter a unique email address.");
        }
Esempio n. 2
0
        public void ShouldRequirePasswordConfirmationMatchesInitialPassword()
        {
            var command = new RegisterEmployee.Command
            {
                Email       = SampleEmail(),
                FirstName   = SampleFirstName(),
                LastName    = SampleLastName(),
                Title       = SampleTitle(),
                Office      = Sample <Office>(),
                PhoneNumber = SamplePhoneNumber()
            };

            command.Password        = null;
            command.ConfirmPassword = "******";
            command.ShouldNotValidate("'Initial Password' must not be empty.");

            command.Password        = "******";
            command.ConfirmPassword = null;
            command.ShouldNotValidate("'Confirm Initial Password' must not be empty.");

            command.Password        = "******";
            command.ConfirmPassword = "******";
            command.ShouldValidate();

            command.Password        = "******";
            command.ConfirmPassword = "******";
            command.ShouldNotValidate("These passwords do not match. Be sure to enter the same password twice.");
        }
        public static async Task <Employee> Register(Action <RegisterEmployee.Command> customize = null)
        {
            var password = SamplePassword();

            var command = new RegisterEmployee.Command
            {
                Email           = SampleEmail(),
                Password        = password,
                ConfirmPassword = password,
                FirstName       = SampleFirstName(),
                LastName        = SampleLastName(),
                Title           = SampleTitle(),
                Office          = Sample <Office>(),
                PhoneNumber     = SamplePhoneNumber()
            };

            customize?.Invoke(command);

            var employeeId = (await Send(command)).EmployeeId;

            return(Query <Employee>(employeeId));
        }
Esempio n. 4
0
        public void ShouldRequireValidEmailAddress()
        {
            var password = SamplePassword();
            var command  = new RegisterEmployee.Command
            {
                Password        = password,
                ConfirmPassword = password,
                FirstName       = "John",
                LastName        = "Smith",
                Title           = "Junior Consultant",
                Office          = Office.Houston,
                PhoneNumber     = "555-123-9999"
            };

            command.ShouldNotValidate("'Email' must not be empty.");

            command.Email = SampleEmail();
            command.ShouldValidate();

            command.Email = "test at example dot com";
            command.ShouldNotValidate("'Email' is not a valid email address.");
        }
Esempio n. 5
0
 public async Task <ActionResult <Employee> > Register(RegisterEmployee.Command command)
 {
     return(await Mediator.Send(command));
 }