コード例 #1
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");
            }
コード例 #2
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");
            }
コード例 #3
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*");
            }