Exemple #1
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.");
        }
Exemple #2
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.");
        }
Exemple #3
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.");
        }