Beispiel #1
0
        public async Task Should_not_add_error_if_references_are_valid()
        {
            var sut = Field(new ReferencesFieldProperties());

            await sut.ValidateAsync(CreateValue(ref1), errors, ValidationTestExtensions.References(ref1));

            Assert.Empty(errors);
        }
        public async Task Should_not_add_error_if_reference_are_not_valid_but_in_optimized_mode()
        {
            var sut = Field(new ReferencesFieldProperties {
                SchemaId = schemaId
            });

            await sut.ValidateAsync(CreateValue(ref1), errors, ValidationTestExtensions.References().Optimized());

            Assert.Empty(errors);
        }
        public async Task Should_add_error_if_reference_are_not_valid()
        {
            var sut = Field(new ReferencesFieldProperties {
                SchemaId = schemaId
            });

            await sut.ValidateAsync(CreateValue(ref1), errors, ValidationTestExtensions.References());

            errors.Should().BeEquivalentTo(
                new[] { $"Contains invalid reference '{ref1}'." });
        }
Beispiel #4
0
        public async Task Should_add_error_if_unique_constraint_failed()
        {
            var sut = Field(new NumberFieldProperties {
                IsUnique = true
            });

            await sut.ValidateAsync(CreateValue(12.5), errors, ValidationTestExtensions.References(Guid.NewGuid()));

            errors.Should().BeEquivalentTo(
                new[] { "Another content with the same value exists." });
        }
Beispiel #5
0
        public async Task Should_add_error_if_value_has_not_enough_items()
        {
            var sut = Field(new ReferencesFieldProperties {
                SchemaId = schemaId, MinItems = 3
            });

            await sut.ValidateAsync(CreateValue(ref1, ref2), errors, ValidationTestExtensions.References(ref1, ref2));

            errors.Should().BeEquivalentTo(
                new[] { "Must have at least 3 item(s)." });
        }
        public async Task Should_add_error_if_reference_contains_duplicate_values()
        {
            var sut = Field(new ReferencesFieldProperties {
                SchemaId = schemaId
            });

            await sut.ValidateAsync(CreateValue(ref1, ref1), errors, ValidationTestExtensions.References(ref1));

            errors.Should().BeEquivalentTo(
                new[] { "Must not contain duplicate values." });
        }
        public async Task Should_add_error_if_value_has_too_much_items()
        {
            var sut = Field(new ReferencesFieldProperties {
                SchemaId = schemaId, MaxItems = 1
            });

            await sut.ValidateAsync(CreateValue(ref1, ref2), errors, ValidationTestExtensions.References(ref1, ref2));

            errors.Should().BeEquivalentTo(
                new[] { "Must not have more than 1 item(s)." });
        }
Beispiel #8
0
        public async Task Should_add_errors_if_asset_are_not_valid()
        {
            var assetId = Guid.NewGuid();

            var sut = new AssetsField(1, "my-asset", Partitioning.Invariant);

            await sut.ValidateAsync(CreateValue(assetId), errors, ValidationTestExtensions.InvalidContext(assetId));

            errors.ShouldBeEquivalentTo(
                new[] { $"<FIELD> contains invalid asset '{assetId}'." });
        }
Beispiel #9
0
        public async Task Should_add_errors_if_reference_are_not_valid()
        {
            var referenceId = Guid.NewGuid();

            var sut = Field(new ReferencesFieldProperties {
                SchemaId = schemaId
            });

            await sut.ValidateAsync(CreateValue(referenceId), errors, ValidationTestExtensions.InvalidReferences(referenceId));

            errors.ShouldBeEquivalentTo(
                new[] { $"<FIELD> contains invalid reference '{referenceId}'." });
        }
 public AssetsFieldTests()
 {
     ctx = ValidationTestExtensions.Assets(image1, image2, document);
 }