Beispiel #1
0
            public void Validate_GivenAllPropertiesAreValid_ExpectValidationSuccess()
            {
                var model = new EditUser.Model
                {
                    FirstName = "first-name", LastName = "last-name", EmailAddress = "*****@*****.**",
                    UserId    = TestVariables.UserId,
                };
                var validator = new EditUser.Validator();
                var result    = validator.Validate(model);

                Assert.True(result.IsValid);
            }
Beispiel #2
0
            public void Validate_GivenEmailAddressIsNull_ExpectValidationFailure()
            {
                var model = new EditUser.Model
                {
                    FirstName = "first-name", LastName = "last-name", EmailAddress = null,
                    UserId    = TestVariables.UserId,
                };
                var validator = new EditUser.Validator();
                var result    = validator.Validate(model);

                Assert.False(result.IsValid);
                Assert.Contains(result.Errors, x => x.PropertyName == "EmailAddress");
            }
Beispiel #3
0
            public void Validate_GivenUserIdIsEmpty_ExpectValidationFailure()
            {
                var model = new EditUser.Model
                {
                    FirstName = "first-name", LastName = "last-name", EmailAddress = "*****@*****.**", UserId = Guid.Empty
                };
                var validator = new EditUser.Validator();
                var result    = validator.Validate(model);

                Assert.False(result.IsValid);
                Assert.Contains(
                    result.Errors,
                    failure => failure.PropertyName == "UserId");
            }
Beispiel #4
0
            public void Validate_GivenLastNameIsNull_ExpectValidationFailure()
            {
                var cmd = new EditUser.Model
                {
                    FirstName = "first-name", LastName = null, EmailAddress = "*****@*****.**", UserId = TestVariables.UserId,
                };
                var validator = new EditUser.Validator();
                var result    = validator.Validate(cmd);

                Assert.False(result.IsValid);
                Assert.Contains(
                    result.Errors,
                    failure => failure.PropertyName == "LastName");
            }