public void When_validating_nested_properties_that_are_null_it_should_not_throw_on_cyclic_references()
        {
            // Arrange
            var actual = new CyclicRoot {
                Text = null
            };

            actual.Level = new CyclicLevel1 {
                Text = null, Root = null
            };

            var expectation = new CyclicRootDto {
                Text = null
            };

            expectation.Level = new CyclicLevel1Dto {
                Text = null, Root = null
            };

            // Act
            Action act = () => actual.Should().BeEquivalentTo(expectation);

            // Assert
            act.Should().NotThrow();
        }
        public void When_validating_nested_properties_and_ignoring_cyclic_references_it_should_succeed()
        {
            // Arrange
            var cyclicRoot = new CyclicRoot {
                Text = "Root"
            };

            cyclicRoot.Level = new CyclicLevel1 {
                Text = "Level1", Root = cyclicRoot
            };

            var cyclicRootDto = new CyclicRootDto {
                Text = "Root"
            };

            cyclicRootDto.Level = new CyclicLevel1Dto {
                Text = "Level1", Root = cyclicRootDto
            };

            // Act
            Action act = () =>
                         cyclicRoot.Should().BeEquivalentTo(cyclicRootDto, options => options.IgnoringCyclicReferences());

            // Assert
            act.Should().NotThrow();
        }
        public void When_validating_nested_properties_that_have_cyclic_references_it_should_throw()
        {
            // Arrange
            var cyclicRoot = new CyclicRoot {
                Text = "Root"
            };

            cyclicRoot.Level = new CyclicLevel1 {
                Text = "Level1", Root = cyclicRoot
            };

            var cyclicRootDto = new CyclicRootDto {
                Text = "Root"
            };

            cyclicRootDto.Level = new CyclicLevel1Dto {
                Text = "Level1", Root = cyclicRootDto
            };

            // Act
            Action act = () => cyclicRoot.Should().BeEquivalentTo(cyclicRootDto);

            // Assert
            act
            .Should().Throw <XunitException>()
            .WithMessage("Expected property cyclicRoot.Level.Root to be*but it contains a cyclic reference*");
        }