public void PropertyValueAccessorSetBooleanTest()
        {
            // Arrange
            PropertyInfo propertyInfo = typeof(EntityWithProperties).GetProperty("Boolean");
            var valueAccessor = new PropertyValueAccessor<EntityWithProperties>(propertyInfo);
            var entity = new EntityWithProperties {Boolean = true};
            const bool newValue = false;

            // Act
            valueAccessor.SetValue(entity, new EntityProperty(newValue));

            // Assert
            Assert.Equal(entity.Boolean, newValue);
        }
Пример #2
0
        public void PropertyValueAccessorSetNullableInt32EnumTest()
        {
            // Arrange
            PropertyInfo propertyInfo  = typeof(EntityWithProperties).GetProperty("NullableInt32Enum");
            var          valueAccessor = new PropertyValueAccessor <EntityWithProperties>(propertyInfo);
            var          entity        = new EntityWithProperties {
                NullableInt32Enum = null
            };
            MyInt32Enum?newValue = MyInt32Enum.NA;

            // Act
            valueAccessor.SetValue(entity, new EntityProperty((Int32?)newValue));

            // Assert
            Assert.Equal(newValue, entity.NullableInt32Enum);
        }
Пример #3
0
        public void PropertyValueAccessorSetStringTest()
        {
            // Arrange
            PropertyInfo propertyInfo  = typeof(EntityWithProperties).GetProperty("String");
            var          valueAccessor = new PropertyValueAccessor <EntityWithProperties>(propertyInfo);
            var          entity        = new EntityWithProperties {
                String = "aabbcc"
            };
            const string newValue = "ccbbaa";

            // Act
            valueAccessor.SetValue(entity, new EntityProperty(newValue));

            // Assert
            Assert.Equal(entity.String, newValue);
        }
Пример #4
0
        public void PropertyValueAccessorSetInt32EnumTest()
        {
            // Arrange
            PropertyInfo propertyInfo  = typeof(EntityWithProperties).GetProperty("Int32Enum");
            var          valueAccessor = new PropertyValueAccessor <EntityWithProperties>(propertyInfo);
            var          entity        = new EntityWithProperties {
                Int32Enum = MyInt32Enum.A
            };
            const MyInt32Enum newValue = MyInt32Enum.B;

            // Act
            valueAccessor.SetValue(entity, new EntityProperty((Int32)newValue));

            // Assert
            Assert.Equal(newValue, entity.Int32Enum);
        }
Пример #5
0
        public void PropertyValueAccessorSetInt64Test()
        {
            // Arrange
            PropertyInfo propertyInfo  = typeof(EntityWithProperties).GetProperty("Int64");
            var          valueAccessor = new PropertyValueAccessor <EntityWithProperties>(propertyInfo);
            var          entity        = new EntityWithProperties {
                Int64 = 2
            };
            const Int64 newValue = 5;

            // Act
            valueAccessor.SetValue(entity, new EntityProperty(newValue));

            // Assert
            Assert.Equal(entity.Int64, newValue);
        }
Пример #6
0
        public void PropertyValueAccessorSetNullableInt64Test()
        {
            // Arrange
            PropertyInfo propertyInfo  = typeof(EntityWithProperties).GetProperty("NullableInt64");
            var          valueAccessor = new PropertyValueAccessor <EntityWithProperties>(propertyInfo);
            var          entity        = new EntityWithProperties {
                NullableInt64 = null
            };
            Int64?newValue = 5;

            // Act
            valueAccessor.SetValue(entity, new EntityProperty(newValue));

            // Assert
            Assert.Equal(entity.NullableInt64, newValue);
        }
Пример #7
0
        public void PropertyValueAccessorSetNullableGuidTest()
        {
            // Arrange
            PropertyInfo propertyInfo  = typeof(EntityWithProperties).GetProperty("NullableGuid");
            var          valueAccessor = new PropertyValueAccessor <EntityWithProperties>(propertyInfo);
            var          entity        = new EntityWithProperties {
                NullableGuid = null
            };
            Guid?newValue = Guid.NewGuid();

            // Act
            valueAccessor.SetValue(entity, new EntityProperty(newValue));

            // Assert
            Assert.Equal(entity.NullableGuid, newValue);
        }
Пример #8
0
        public void PropertyValueAccessorSetNullableDoubleTest()
        {
            // Arrange
            PropertyInfo propertyInfo  = typeof(EntityWithProperties).GetProperty("NullableDouble");
            var          valueAccessor = new PropertyValueAccessor <EntityWithProperties>(propertyInfo);
            var          entity        = new EntityWithProperties {
                NullableDouble = 0.3
            };
            Double?newValue = 0.5;

            // Act
            valueAccessor.SetValue(entity, new EntityProperty(newValue));

            // Assert
            Assert.Equal(entity.NullableDouble, newValue);
        }
Пример #9
0
        public void PropertyValueAccessorSetNullableDateTimeOffsetTest()
        {
            // Arrange
            PropertyInfo propertyInfo  = typeof(EntityWithProperties).GetProperty("NullableDateTimeOffset");
            var          valueAccessor = new PropertyValueAccessor <EntityWithProperties>(propertyInfo);
            var          entity        = new EntityWithProperties {
                NullableDateTimeOffset = null
            };
            DateTimeOffset?newValue = DateTime.UtcNow;

            // Act
            valueAccessor.SetValue(entity, new EntityProperty(newValue));

            // Assert
            Assert.Equal(entity.NullableDateTimeOffset, newValue);
        }
Пример #10
0
        public void PropertyValueAccessorSetDateTimeOffsetTest()
        {
            // Arrange
            PropertyInfo propertyInfo  = typeof(EntityWithProperties).GetProperty("DateTimeOffset");
            var          valueAccessor = new PropertyValueAccessor <EntityWithProperties>(propertyInfo);
            var          entity        = new EntityWithProperties {
                DateTimeOffset = DateTime.Today
            };
            DateTimeOffset newValue = DateTime.Now;

            // Act
            valueAccessor.SetValue(entity, new EntityProperty(newValue));

            // Assert
            Assert.Equal(entity.DateTimeOffset, newValue);
        }
Пример #11
0
        public void PropertyValueAccessorSetNullableBooleanTest()
        {
            // Arrange
            PropertyInfo propertyInfo  = typeof(EntityWithProperties).GetProperty("NullableBoolean");
            var          valueAccessor = new PropertyValueAccessor <EntityWithProperties>(propertyInfo);
            var          entity        = new EntityWithProperties {
                NullableBoolean = true
            };
            const bool newValue = false;

            // Act
            valueAccessor.SetValue(entity, new EntityProperty(newValue));

            // Assert
            Assert.Equal(entity.NullableBoolean, newValue);
        }
Пример #12
0
        public void PropertyValueAccessorSetByteTest()
        {
            // Arrange
            PropertyInfo propertyInfo  = typeof(EntityWithProperties).GetProperty("Binary");
            var          valueAccessor = new PropertyValueAccessor <EntityWithProperties>(propertyInfo);
            var          entity        = new EntityWithProperties {
                Binary = new byte[] { 0x11, 0x22, 0x33 }
            };
            var newValue = new byte[] { 0x33, 0x22, 0x11 };

            // Act
            valueAccessor.SetValue(entity, new EntityProperty(newValue));

            // Assert
            Assert.Equal(entity.Binary, newValue);
        }
        public void PropertyValueAccessorSetStringTest()
        {
            // Arrange
            PropertyInfo propertyInfo = typeof(EntityWithProperties).GetProperty("String");
            var valueAccessor = new PropertyValueAccessor<EntityWithProperties>(propertyInfo);
            var entity = new EntityWithProperties { String = "aabbcc" };
            const string newValue = "ccbbaa";

            // Act
            valueAccessor.SetValue(entity, new EntityProperty(newValue));

            // Assert
            Assert.Equal(entity.String, newValue);
        }
        public void PropertyValueAccessorSetInt32EnumTest()
        {
            // Arrange
            PropertyInfo propertyInfo = typeof(EntityWithProperties).GetProperty("Int32Enum");
            var valueAccessor = new PropertyValueAccessor<EntityWithProperties>(propertyInfo);
            var entity = new EntityWithProperties { Int32Enum = MyInt32Enum.A };
            const MyInt32Enum newValue = MyInt32Enum.B;

            // Act
            valueAccessor.SetValue(entity, new EntityProperty((Int32)newValue));

            // Assert
            Assert.Equal(newValue, entity.Int32Enum);
        }
        public void PropertyValueAccessorSetNullableInt32EnumTest()
        {
            // Arrange
            PropertyInfo propertyInfo = typeof(EntityWithProperties).GetProperty("NullableInt32Enum");
            var valueAccessor = new PropertyValueAccessor<EntityWithProperties>(propertyInfo);
            var entity = new EntityWithProperties { NullableInt32Enum = null };
            MyInt32Enum? newValue = MyInt32Enum.NA;

            // Act
            valueAccessor.SetValue(entity, new EntityProperty((Int32?)newValue));

            // Assert
            Assert.Equal(newValue, entity.NullableInt32Enum);
        }
        public void PropertyValueAccessorSetNullableInt64Test()
        {
            // Arrange
            PropertyInfo propertyInfo = typeof(EntityWithProperties).GetProperty("NullableInt64");
            var valueAccessor = new PropertyValueAccessor<EntityWithProperties>(propertyInfo);
            var entity = new EntityWithProperties { NullableInt64 = null };
            Int64? newValue = 5;

            // Act
            valueAccessor.SetValue(entity, new EntityProperty(newValue));

            // Assert
            Assert.Equal(entity.NullableInt64, newValue);
        }
        public void PropertyValueAccessorSetInt64Test()
        {
            // Arrange
            PropertyInfo propertyInfo = typeof(EntityWithProperties).GetProperty("Int64");
            var valueAccessor = new PropertyValueAccessor<EntityWithProperties>(propertyInfo);
            var entity = new EntityWithProperties { Int64 = 2 };
            const Int64 newValue = 5;

            // Act
            valueAccessor.SetValue(entity, new EntityProperty(newValue));

            // Assert
            Assert.Equal(entity.Int64, newValue);
        }
        public void PropertyValueAccessorSetNullableGuidTest()
        {
            // Arrange
            PropertyInfo propertyInfo = typeof(EntityWithProperties).GetProperty("NullableGuid");
            var valueAccessor = new PropertyValueAccessor<EntityWithProperties>(propertyInfo);
            var entity = new EntityWithProperties { NullableGuid = null };
            Guid? newValue = Guid.NewGuid();

            // Act
            valueAccessor.SetValue(entity, new EntityProperty(newValue));

            // Assert
            Assert.Equal(entity.NullableGuid, newValue);
        }
        public void PropertyValueAccessorSetNullableDoubleTest()
        {
            // Arrange
            PropertyInfo propertyInfo = typeof(EntityWithProperties).GetProperty("NullableDouble");
            var valueAccessor = new PropertyValueAccessor<EntityWithProperties>(propertyInfo);
            var entity = new EntityWithProperties { NullableDouble = 0.3 };
            Double? newValue = 0.5;

            // Act
            valueAccessor.SetValue(entity, new EntityProperty(newValue));

            // Assert
            Assert.Equal(entity.NullableDouble, newValue);
        }
        public void PropertyValueAccessorSetNullableDateTimeOffsetTest()
        {
            // Arrange
            PropertyInfo propertyInfo = typeof(EntityWithProperties).GetProperty("NullableDateTimeOffset");
            var valueAccessor = new PropertyValueAccessor<EntityWithProperties>(propertyInfo);
            var entity = new EntityWithProperties { NullableDateTimeOffset = null };
            DateTimeOffset? newValue = DateTime.UtcNow;

            // Act
            valueAccessor.SetValue(entity, new EntityProperty(newValue));

            // Assert
            Assert.Equal(entity.NullableDateTimeOffset, newValue);
        }
        public void PropertyValueAccessorSetDateTimeOffsetTest()
        {
            // Arrange
            PropertyInfo propertyInfo = typeof(EntityWithProperties).GetProperty("DateTimeOffset");
            var valueAccessor = new PropertyValueAccessor<EntityWithProperties>(propertyInfo);
            var entity = new EntityWithProperties { DateTimeOffset = DateTime.Today };
            DateTimeOffset newValue = DateTime.Now;

            // Act
            valueAccessor.SetValue(entity, new EntityProperty(newValue));

            // Assert
            Assert.Equal(entity.DateTimeOffset, newValue);
        }
Пример #22
0
 public void SetActualItemColumnValue(string columnName, object value)
 => PropertyValueAccessor.SetValue(ActualItem, columnName, value);
        public void PropertyValueAccessorSetByteTest()
        {
            // Arrange
            PropertyInfo propertyInfo = typeof(EntityWithProperties).GetProperty("Binary");
            var valueAccessor = new PropertyValueAccessor<EntityWithProperties>(propertyInfo);
            var entity = new EntityWithProperties { Binary = new byte[]{0x11, 0x22, 0x33} };
            var newValue = new byte[] {0x33, 0x22, 0x11};

            // Act
            valueAccessor.SetValue(entity, new EntityProperty(newValue));

            // Assert
            Assert.Equal(entity.Binary, newValue);
        }