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

            // Act & Assert
            ExceptionAssert.ThrowsArgument(() => StructPropertyGetter <PocoStruct, PocoProperty> .Create(property),
                                           "property", "The property must not be static.");
        }
예제 #2
0
        public void Create_IfPropertyIsWriteOnly_Throws()
        {
            // Arrange
            PropertyInfo property = typeof(PocoStruct).GetProperty("WriteOnlyValue");

            // Act & Assert
            ExceptionAssert.ThrowsArgument(() => StructPropertyGetter <PocoStruct, PocoProperty> .Create(property),
                                           "property", "The property must be readable.");
        }
예제 #3
0
        public void Create_IfPropertyHasIndexParameters_Throws()
        {
            // Arrange
            PropertyInfo property = typeof(PocoStruct).GetProperty("Item");

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

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

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

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

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

            // Act
            IPropertyGetter <PocoStruct, PocoProperty> getter = StructPropertyGetter <PocoStruct, PocoProperty> .Create(
                property);

            // Assert
            Assert.NotNull(getter);
        }