Example #1
0
        public void Excluding_a_covariant_property_should_work()
        {
            // Arrange
            var actual = new DerivedWithCovariantOverride(new DerivedWithProperty {
                DerivedProperty = "a", BaseProperty = "a_base"
            })
            {
                OtherProp = "other"
            };

            var expectation = new DerivedWithCovariantOverride(new DerivedWithProperty {
                DerivedProperty = "b", BaseProperty = "b_base"
            })
            {
                OtherProp = "other"
            };

            // Act / Assert
            actual.Should().BeEquivalentTo(expectation, opts => opts
                                           .Excluding(d => d.Property));
        }
Example #2
0
        public void Excluding_a_covariant_property_through_the_base_class_excludes_the_base_class_property()
        {
            // Arrange
            var actual = new DerivedWithCovariantOverride(new DerivedWithProperty {
                DerivedProperty = "a", BaseProperty = "a_base"
            })
            {
                OtherProp = "other"
            };

            BaseWithAbstractProperty expectation = new DerivedWithCovariantOverride(new DerivedWithProperty {
                DerivedProperty = "b", BaseProperty = "b_base"
            })
            {
                OtherProp = "other"
            };

            // Act
            Action act = () => actual.Should().BeEquivalentTo(expectation, opts => opts
                                                              .Excluding(d => d.Property));

            // Assert
            act.Should().Throw <InvalidOperationException>().WithMessage("No members*");
        }