Ejemplo n.º 1
0
        public void When_two_instances_are_equivalent_it_should_succeed()
        {
            // Arrange
            var subject  = new ComparableCustomer(42);
            var expected = new CustomerDTO(42);

            // Act / Assert
            subject.Should().BeEquivalentTo(expected);
        }
Ejemplo n.º 2
0
        public void When_two_instances_are_compared_with_config_it_should_allow_chaining()
        {
            // Arrange
            var subject  = new ComparableCustomer(42);
            var expected = new CustomerDTO(42);

            // Act / Assert
            subject.Should().BeEquivalentTo(expected, opt => opt)
            .And.NotBeNull();
        }
Ejemplo n.º 3
0
        public void When_injecting_a_null_config_it_should_throw()
        {
            // Arrange
            var subject  = new ComparableCustomer(42);
            var expected = new AnotherCustomerDTO(42);

            // Act
            Action act = () => subject.Should().BeEquivalentTo(expected, config: null);

            // Assert
            act.Should().ThrowExactly <ArgumentNullException>()
            .Which.ParamName.Should().Be("config");
        }
Ejemplo n.º 4
0
        public void When_two_instances_are_equivalent_due_to_exclusion_it_should_succeed()
        {
            // Arrange
            var subject  = new ComparableCustomer(42);
            var expected = new AnotherCustomerDTO(42)
            {
                SomeOtherProperty = 1337
            };

            // Act / Assert
            subject.Should().BeEquivalentTo(expected,
                                            options => options.Excluding(x => x.SomeOtherProperty),
                                            "they have the same property values");
        }
Ejemplo n.º 5
0
        public void When_two_instances_are_not_equivalent_it_should_throw()
        {
            // Arrange
            var subject  = new ComparableCustomer(42);
            var expected = new AnotherCustomerDTO(42)
            {
                SomeOtherProperty = 1337
            };

            // Act
            Action act = () => subject.Should().BeEquivalentTo(expected, "they have the same property values");

            // Assert
            act
            .Should().Throw <XunitException>()
            .WithMessage(
                "Expectation has member SomeOtherProperty that the other object does not have*");
        }