public async Task Should_not_add_error_if_references_are_null_and_valid()
        {
            var sut = new ReferencesField(1, "my-refs", Partitioning.Invariant);

            await sut.ValidateAsync(CreateValue(null), errors);

            Assert.Empty(errors);
        }
        public async Task Should_add_errors_if_value_is_not_valid()
        {
            var sut = new ReferencesField(1, "my-refs", Partitioning.Invariant);

            await sut.ValidateAsync("invalid", errors);

            errors.ShouldBeEquivalentTo(
                new[] { "<FIELD> is not a valid value" });
        }
        public async Task Should_not_add_error_if_references_are_valid()
        {
            var referenceId = Guid.NewGuid();

            var sut = new ReferencesField(1, "my-refs", Partitioning.Invariant);

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

            Assert.Empty(errors);
        }
        public async Task Should_add_errors_if_value_has_not_enough_items()
        {
            var sut = new ReferencesField(1, "my-refs", Partitioning.Invariant, new ReferencesFieldProperties {
                SchemaId = schemaId, MinItems = 3
            });

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

            errors.ShouldBeEquivalentTo(
                new[] { "<FIELD> must have at least 3 reference(s)" });
        }
        public async Task Should_add_errors_if_references_are_required_and_empty()
        {
            var sut = new ReferencesField(1, "my-refs", Partitioning.Invariant, new ReferencesFieldProperties {
                SchemaId = schemaId, IsRequired = true
            });

            await sut.ValidateAsync(CreateValue(), errors);

            errors.ShouldBeEquivalentTo(
                new[] { "<FIELD> is required" });
        }
        public async Task Should_add_errors_if_reference_are_not_valid()
        {
            var referenceId = Guid.NewGuid();

            var sut = new ReferencesField(1, "my-refs", Partitioning.Invariant, new ReferencesFieldProperties {
                SchemaId = schemaId
            });

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

            errors.ShouldBeEquivalentTo(
                new[] { $"<FIELD> contains invalid reference '{referenceId}'" });
        }