예제 #1
0
        public void CreatePatronCommand_Defaults_IsAnonymous()
        {
            CreatePatron command = new CreatePatron("Create User", TestHelper.Now);

            Assert.False(command.IsAnonymous, "Default Value of CreatePatronCommand.IsAnonymous changed from 'false'.");
            Assert.Null(command.DisplayName);
            Assert.Null(command.PatronType);
        }
예제 #2
0
        public void Validation_Requires_DisplayName_and_PatronType()
        {
            CreatePatron command = new CreatePatron("Create User", TestHelper.Now);

            List <ValidationResult> validationResults = new List <ValidationResult>();

            Validator.TryValidateObject(command, new ValidationContext(command), validationResults, true);

            Assert.Contains(validationResults, vr => vr.MemberNames.Any(mn => mn == nameof(CreatePatron.DisplayName)));
            Assert.Contains(validationResults, vr => vr.MemberNames.Any(mn => mn == nameof(CreatePatron.PatronType)));
            Assert.DoesNotContain(validationResults, vr => vr.MemberNames.Any(mn => mn == nameof(CreatePatron.IsAnonymous)));
        }
예제 #3
0
        public void Validation_On_DisplayName_Has_Maximum_String_Length()
        {
            CreatePatron command = new CreatePatron("Create User", TestHelper.Now)
            {
                DisplayName = "This is a string with lots of letters appended.".PadRight(1000, 'A'),
                PatronType  = "Invalid Type"
            };

            List <ValidationResult> validationResults = new List <ValidationResult>();

            Validator.TryValidateObject(command, new ValidationContext(command), validationResults, true);

            Assert.Contains(validationResults, vr => vr.MemberNames.Any(mn => mn == nameof(CreatePatron.DisplayName)));
            Assert.DoesNotContain(validationResults, vr => vr.MemberNames.Any(mn => mn == nameof(CreatePatron.PatronType)));
            Assert.DoesNotContain(validationResults, vr => vr.MemberNames.Any(mn => mn == nameof(CreatePatron.IsAnonymous)));
        }