public void ValidateField_WhenFieldValueDoesConformToExpectedType_ShouldReturnNull()
        {
            // Arrange
            DatatypeMismatchFieldValidator validatorUnderTest = new DatatypeMismatchFieldValidator();
            FieldDefinition fieldDefinition = new FieldDefinition()
            {
                Description         = "The name of the provider",
                Id                  = "1100004",
                IdentifierFieldType = null,
                MatchExpression     = null,
                Maximum             = null,
                Minimum             = null,
                Name                = "Provider Name",
                Required            = false,
                Type                = FieldType.String
            };

            const int anyRow    = 1;
            const int anyColumn = 1;

            // Act
            FieldValidationResult result =
                validatorUnderTest
                .ValidateField(new Field(new DatasetUploadCellReference(anyRow, anyColumn), "Correct value type", fieldDefinition));

            // Assert
            result
            .Should().BeNull();
        }
Пример #2
0
        private IList <IFieldValidator> GetFieldValidators(IEnumerable <ProviderSummary> providerSummaries)
        {
            if (FieldValidators.IsNullOrEmpty())
            {
                IFieldValidator requiredValidator              = new RequiredValidator();
                IFieldValidator providerBlankValidator         = new ProviderIdentifierBlankValidator();
                IFieldValidator dataTypeMismatchFieldValidator = new DatatypeMismatchFieldValidator();
                IFieldValidator providerExistsValidator        = new ProviderExistsValidator(providerSummaries.ToList());
                IFieldValidator maxAndMinFieldValidator        = new MaxAndMinFieldValidator();

                return(new List <IFieldValidator>
                {
                    providerBlankValidator,
                    requiredValidator,
                    dataTypeMismatchFieldValidator,
                    providerExistsValidator,
                    maxAndMinFieldValidator,
                    providerExistsValidator
                });
            }

            return(FieldValidators);
        }