Exemple #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);
            }
Exemple #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();
            }
Exemple #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>()
                .WithParameterName("config");
            }
Exemple #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");
            }
Exemple #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 property subject.SomeOtherProperty*that the other object does not have*");
            }