public void When_object_with_invariants_Then_returns_errors()
        {
            // Arrange
            ValidationResult[] expected = Expectation
                                          .Result("InvariantA.", "InvariantA")
                                          .Result("InvariantB.", "InvariantB");

            var source = new ClassWithInvariants();

            // Act
            var actual = sut.Validate(source);

            // Assert
            actual.Should().BeEquivalentTo(expected);
        }
        public void When_object_with_validation_attributes_Then_returns_errors()
        {
            // Arrange
            ValidationResult[] expected = Expectation
                                          .Result("The RequiredStringProperty field is required.", "RequiredStringProperty")
                                          .Result("The field ComplexStringProperty must be a string or array type with a minimum length of '2'.", "ComplexStringProperty")
                                          .Result("The ComplexStringProperty field is not a valid e-mail address.", "ComplexStringProperty")
                                          .Result("The field RangedIntProperty must be between 21 and 65.", "RangedIntProperty");

            var source = new ClassWithInvalidProperties();

            // Act
            var actual = sut.Validate(source);

            // Assert
            actual.Should().BeEquivalentTo(expected);
        }
        public void When_object_with_circular_object_reference_Then_returns_errors()
        {
            // Arrange
            ValidationResult[] expected = Expectation
                                          .Result("The StringProperty field is required.", "StringProperty")
                                          .Result("The StringProperty field is required.", "ReferenceProperty.StringProperty");

            var source        = new ClassWithCircularReferences();
            var backReference = new ClassWithBackReference();

            // circular reference
            source.ReferenceProperty        = backReference;
            backReference.ReferenceProperty = source;

            // Act
            var actual = sut.Validate(source);

            // Assert
            actual.Should().BeEquivalentTo(expected);
        }