Exemplo n.º 1
0
        private void InternalHasValidationResult_Taxonomy_CreateValidationResults(string propertyKey, List <string> taxonomyList, List <string> expectedList)
        {
            // Arrange
            Resource resource         = CreateResourceWithTaxonomyProperty(propertyKey, taxonomyList.Cast <dynamic>().ToList(), out var property);
            var      validationFacade = new EntityValidationFacade(ResourceCrudAction.Create, resource, null, null, _metadata, null);

            // Act
            _validator.HasValidationResult(validationFacade, property);

            // Assert
            var resultValue = resource.Properties.FirstOrDefault(p => p.Key == propertyKey).Value;

            Assert.Equal(expectedList.Cast <dynamic>().OrderBy(t => t), resultValue.OrderBy(t => t));
            Assert.Empty(validationFacade.ValidationResults);
        }
Exemplo n.º 2
0
        public void InternalHasValidationResult_Taxonomy_InvalidValues(string propertyKey, string taxonomyId)
        {
            // Arrange
            Resource resource = CreateResourceWithTaxonomyProperty(propertyKey, new List <dynamic>()
            {
                taxonomyId
            }, out var property);
            EntityValidationFacade validationFacade = new EntityValidationFacade(ResourceCrudAction.Create, resource, null, null, _metadata, null);

            // Act
            _validator.HasValidationResult(validationFacade, property);

            // Assert
            Assert.Single(validationFacade.ValidationResults);
            Assert.Collection(validationFacade.ValidationResults, validationResult => AssertValidationResult(validationResult, taxonomyId));
        }