Ejemplo n.º 1
0
        public void PrintExcludesWriteOnlyProperties()
        {
            // Arrange
            MockObjectVisitor          visitor = CreateObjectVisitor();
            ClassWithWriteOnlyProperty cls     = new ClassWithWriteOnlyProperty();

            // Act
            visitor.Print(cls);

            // Assert
            Assert.Equal(0, visitor.Members.Count);
        }
        public void When_a_subject_has_a_write_only_property_it_should_ignore_that_property()
        {
            //-----------------------------------------------------------------------------------------------------------
            // Arrange
            //-----------------------------------------------------------------------------------------------------------
            var subject = new ClassWithWriteOnlyProperty
            {
                WriteOnlyProperty = 123,
                SomeOtherProperty = "whatever"
            };

            var expected = new
            {
                SomeOtherProperty = "whatever"
            };

            //-----------------------------------------------------------------------------------------------------------
            // Act
            //-----------------------------------------------------------------------------------------------------------
            Action action = () => subject.ShouldHave().AllProperties().EqualTo(expected);

            //-----------------------------------------------------------------------------------------------------------
            // Assert
            //-----------------------------------------------------------------------------------------------------------
            action.ShouldNotThrow();
        }
Ejemplo n.º 3
0
        public void PrintExcludesWriteOnlyProperties()
        {
            // Arrange
            MockObjectVisitor visitor = CreateObjectVisitor();
            ClassWithWriteOnlyProperty cls = new ClassWithWriteOnlyProperty();

            // Act
            visitor.Print(cls);

            // Assert
            Assert.Equal(0, visitor.Members.Count);
        }