Esempio n. 1
0
        public void Create_IfPropertyIsStatic_Throws()
        {
            // Arrange
            PropertyInfo property = typeof(PocoStruct).GetProperty("StaticValue");

            // Act & Assert
            ExceptionAssert.ThrowsArgument(() => StructPropertySetter <PocoStruct, PocoProperty> .Create(property),
                                           "property", "The property must not be static.");
        }
Esempio n. 2
0
        public void Create_IfPropertyIsReadOnly_Throws()
        {
            // Arrange
            PropertyInfo property = typeof(PocoStruct).GetProperty("ReadOnlyValue");

            // Act & Assert
            ExceptionAssert.ThrowsArgument(() => StructPropertySetter <PocoStruct, PocoProperty> .Create(property),
                                           "property", "The property must be writable.");
        }
Esempio n. 3
0
        public void Create_IfPropertyHasIndexParameters_Throws()
        {
            // Arrange
            PropertyInfo property = typeof(PocoStruct).GetProperty("Item");

            // Act & Assert
            ExceptionAssert.ThrowsArgument(() => StructPropertySetter <PocoStruct, PocoProperty> .Create(property),
                                           "property", "The property must not have index parameters.");
        }
Esempio n. 4
0
        public void Create_IfPropertyTypeMismatchesEvenIfChildType_Throws()
        {
            // Arrange
            PropertyInfo property = typeof(PocoStruct).GetProperty("Value");

            // Act & Assert
            ExceptionAssert.ThrowsArgument(() => StructPropertySetter <PocoStruct, PocoPropertyChild> .Create(property),
                                           "property", "The property's PropertyType must exactly match TProperty.");
        }
Esempio n. 5
0
        public void Create_IfReflectedTypeMismatches_Throws()
        {
            // Arrange
            PropertyInfo property = typeof(PocoStruct).GetProperty("Value");

            // Act & Assert
            ExceptionAssert.ThrowsArgument(() => StructPropertySetter <int, PocoProperty> .Create(property),
                                           "property", "The property's ReflectedType must exactly match TReflected.");
        }
Esempio n. 6
0
        public void Create_IfPropertyIsNull_Throws()
        {
            // Arrange
            PropertyInfo property = null;

            // Act & Assert
            ExceptionAssert.ThrowsArgumentNull(() => StructPropertySetter <PocoStruct, PocoProperty> .Create(property),
                                               "property");
        }
Esempio n. 7
0
        private static StructPropertySetter <TReflected, TProperty> CreateProductUnderTest <TReflected, TProperty>(
            PropertyInfo property) where TReflected : struct
        {
            StructPropertySetter <TReflected, TProperty> product =
                StructPropertySetter <TReflected, TProperty> .Create(property);

            Assert.NotNull(product); // Guard
            return(product);
        }
Esempio n. 8
0
        public void Create_ReturnsInstance()
        {
            // Arrange
            PropertyInfo property = typeof(PocoStruct).GetProperty("Value");

            // Act
            IPropertySetter <PocoStruct, PocoProperty> setter = StructPropertySetter <PocoStruct, PocoProperty> .Create(
                property);

            // Assert
            Assert.NotNull(setter);
        }