コード例 #1
0
        public void Create_IfPropertyHasIndexParameters_Throws()
        {
            // Arrange
            PropertyInfo property = typeof(Poco).GetProperty("Item");

            // Act & Assert
            ExceptionAssert.ThrowsArgument(() => ClassPropertySetter <Poco, PocoProperty> .Create(property), "property",
                                           "The property must not have index parameters.");
        }
コード例 #2
0
        public void Create_IfPropertyTypeMismatchesEvenIfChildType_Throws()
        {
            // Arrange
            PropertyInfo property = typeof(Poco).GetProperty("Value");

            // Act & Assert
            ExceptionAssert.ThrowsArgument(() => ClassPropertySetter <Poco, PocoPropertyChild> .Create(property),
                                           "property", "The property's PropertyType must exactly match TProperty.");
        }
コード例 #3
0
        public void Create_IfPropertyIsReadOnly_Throws()
        {
            // Arrange
            PropertyInfo property = typeof(Poco).GetProperty("ReadOnlyValue");

            // Act & Assert
            ExceptionAssert.ThrowsArgument(() => ClassPropertySetter <Poco, PocoProperty> .Create(property), "property",
                                           "The property must be writable.");
        }
コード例 #4
0
        public void Create_IfReflectedTypeMismatchesEvenIfDeclaringType_Throws()
        {
            // Arrange
            PropertyInfo property = typeof(PocoChild).GetProperty("Value");

            // Act & Assert
            ExceptionAssert.ThrowsArgument(() => ClassPropertySetter <Poco, PocoProperty> .Create(property), "property",
                                           "The property's ReflectedType must exactly match TReflected.");
        }
コード例 #5
0
        public void Create_IfPropertyIsNull_Throws()
        {
            // Arrange
            PropertyInfo property = null;

            // Act & Assert
            ExceptionAssert.ThrowsArgumentNull(() => ClassPropertySetter <Poco, PocoProperty> .Create(property),
                                               "property");
        }
コード例 #6
0
        private static ClassPropertySetter <TReflected, TProperty> CreateProductUnderTest <TReflected, TProperty>(
            PropertyInfo property) where TReflected : class
        {
            ClassPropertySetter <TReflected, TProperty> product =
                ClassPropertySetter <TReflected, TProperty> .Create(property);

            Assert.NotNull(product); // Guard
            return(product);
        }
コード例 #7
0
        public void Create_IfPropertyIsStatic_Throws()
        {
            // Arrange
            PropertyInfo property = typeof(Poco).GetProperty("StaticValue");

            // Act & Assert
            ExceptionAssert.ThrowsArgument(() => ClassPropertySetter <Poco, PocoProperty> .Create(property), "property",
                                           "The property must not be static.");
        }
コード例 #8
0
        public void Create_ReturnsInstance()
        {
            // Arrange
            PropertyInfo property = typeof(Poco).GetProperty("Value");

            // Act
            IPropertySetter <Poco, PocoProperty> setter = ClassPropertySetter <Poco, PocoProperty> .Create(property);

            // Assert
            Assert.NotNull(setter);
        }