コード例 #1
0
        public void GroupDtoValidation_Valid_NoErrors()
        {
            var dto = new GroupDto
            {
                Name = RandomFactory.GetCompanyName(),
            };

            var validationContext = new ValidationContext(dto);

            var validationResults = dto.Validate(validationContext);

            validationResults.Should().HaveCount(0);
        }
コード例 #2
0
        public void GroupDtoValidation_NameTooLong_HasValidationErrors()
        {
            var dto = new GroupDto
            {
                Name = RandomFactory.GetAlphanumericString(Constants.MaximumLengths.StringColumn + 1),
            };

            var validationContext = new ValidationContext(dto);

            var validationResults = dto.Validate(validationContext);

            validationResults.Should().HaveCountGreaterThan(0);
            validationResults.FirstOrDefault(validationResult => validationResult.MemberNames.Any(memberName => memberName.Equals(nameof(GroupDto.Name))))?.Should().NotBeNull();
        }
コード例 #3
0
        public void GroupDtoValidation_MissingName_HasValidationErrors(string name)
        {
            var dto = new GroupDto
            {
                Name = name,
            };

            var validationContext = new ValidationContext(dto);

            var validationResults = dto.Validate(validationContext);

            validationResults.Should().HaveCountGreaterThan(0);
            validationResults.FirstOrDefault(validationResult => validationResult.MemberNames.Any(memberName => memberName.Equals(nameof(GroupDto.Name))))?.Should().NotBeNull();
        }