Exemplo n.º 1
0
        public void Create_IfPropertyHasIndexParameters_Throws()
        {
            // Arrange
            PropertyInfo property = typeof(Poco).GetProperty("Item");

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

            // Act & Assert
            ExceptionAssert.ThrowsArgument(() => ClassPropertyGetter <Poco, PocoPropertyChild> .Create(property),
                                           "property", "The property's PropertyType must exactly match TProperty.");
        }
Exemplo n.º 3
0
        public void Create_IfPropertyIsWriteOnly_Throws()
        {
            // Arrange
            PropertyInfo property = typeof(Poco).GetProperty("WriteOnlyValue");

            // Act & Assert
            ExceptionAssert.ThrowsArgument(() => ClassPropertyGetter <Poco, PocoProperty> .Create(property), "property",
                                           "The property must be readable.");
        }
Exemplo n.º 4
0
        public void Create_IfReflectedTypeMismatchesEvenIfDeclaringType_Throws()
        {
            // Arrange
            PropertyInfo property = typeof(PocoChild).GetProperty("Value");

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

            // Act & Assert
            ExceptionAssert.ThrowsArgumentNull(() => ClassPropertyGetter <Poco, PocoProperty> .Create(property),
                                               "property");
        }
Exemplo n.º 6
0
        private static ClassPropertyGetter <TReflected, TProperty> CreateProductUnderTest <TReflected, TProperty>(
            PropertyInfo property) where TReflected : class
        {
            ClassPropertyGetter <TReflected, TProperty> product =
                ClassPropertyGetter <TReflected, TProperty> .Create(property);

            Assert.NotNull(product); // Guard
            return(product);
        }
Exemplo n.º 7
0
        public void Create_IfPropertyIsStatic_Throws()
        {
            // Arrange
            PropertyInfo property = typeof(Poco).GetProperty("StaticValue");

            // Act & Assert
            ExceptionAssert.ThrowsArgument(() => ClassPropertyGetter <Poco, PocoProperty> .Create(property), "property",
                                           "The property must not be static.");
        }
Exemplo n.º 8
0
        public void Create_ReturnsInstance()
        {
            // Arrange
            PropertyInfo property = typeof(Poco).GetProperty("Value");

            // Act
            IPropertyGetter <Poco, PocoProperty> getter = ClassPropertyGetter <Poco, PocoProperty> .Create(property);

            // Assert
            Assert.NotNull(getter);
        }