Example #1
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);
        }
Example #2
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);
        }
Example #3
0
        public void PropertyValueAccessorGetBooleanTest()
        {
            // Arrange
            PropertyInfo propertyInfo  = typeof(EntityWithProperties).GetProperty("Boolean");
            var          valueAccessor = new PropertyValueAccessor <EntityWithProperties>(propertyInfo);
            const bool   value         = true;
            var          user          = new EntityWithProperties {
                Boolean = value
            };

            // Act
            EntityProperty entityProperty = valueAccessor.GetValue(user);

            // Assert
            Assert.Equal(entityProperty.BooleanValue, value);
        }
Example #4
0
        public void PropertyValueAccessorGetStringTest()
        {
            // Arrange
            PropertyInfo propertyInfo  = typeof(EntityWithProperties).GetProperty("String");
            var          valueAccessor = new PropertyValueAccessor <EntityWithProperties>(propertyInfo);
            const string value         = "aabbcc";
            var          user          = new EntityWithProperties {
                String = value
            };

            // Act
            EntityProperty entityProperty = valueAccessor.GetValue(user);

            // Assert
            Assert.Equal(entityProperty.StringValue, value);
        }
Example #5
0
        public void PropertyValueAccessorGetInt64EnumTest()
        {
            // Arrange
            PropertyInfo      propertyInfo  = typeof(EntityWithProperties).GetProperty("Int64Enum");
            var               valueAccessor = new PropertyValueAccessor <EntityWithProperties>(propertyInfo);
            const MyInt64Enum value         = MyInt64Enum.A;
            var               user          = new EntityWithProperties {
                Int64Enum = value
            };

            // Act
            EntityProperty entityProperty = valueAccessor.GetValue(user);

            // Assert
            Assert.Equal((Int64)value, entityProperty.Int64Value);
        }
Example #6
0
        public void PropertyValueAccessorGetNullableInt64Test()
        {
            // Arrange
            PropertyInfo propertyInfo  = typeof(EntityWithProperties).GetProperty("NullableInt64");
            var          valueAccessor = new PropertyValueAccessor <EntityWithProperties>(propertyInfo);
            Int64?       value         = 3;
            var          user          = new EntityWithProperties {
                NullableInt64 = value
            };

            // Act
            EntityProperty entityProperty = valueAccessor.GetValue(user);

            // Assert
            Assert.Equal(entityProperty.Int64Value, value);
        }
Example #7
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);
        }
Example #8
0
        public void PropertyValueAccessorGetNullableInt32EnumTest()
        {
            // Arrange
            PropertyInfo propertyInfo  = typeof(EntityWithProperties).GetProperty("NullableInt32Enum");
            var          valueAccessor = new PropertyValueAccessor <EntityWithProperties>(propertyInfo);
            MyInt32Enum? value         = MyInt32Enum.NB;
            var          user          = new EntityWithProperties {
                NullableInt32Enum = value
            };

            // Act
            EntityProperty entityProperty = valueAccessor.GetValue(user);

            // Assert
            Assert.Equal((Int32?)value, entityProperty.Int32Value);
        }
Example #9
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);
        }
Example #10
0
        public void PropertyValueAccessorGetNullableGuidTest()
        {
            // Arrange
            PropertyInfo propertyInfo  = typeof(EntityWithProperties).GetProperty("NullableGuid");
            var          valueAccessor = new PropertyValueAccessor <EntityWithProperties>(propertyInfo);
            Guid?        value         = Guid.NewGuid();
            var          user          = new EntityWithProperties {
                NullableGuid = value
            };

            // Act
            EntityProperty entityProperty = valueAccessor.GetValue(user);

            // Assert
            Assert.Equal(entityProperty.GuidValue, value);
        }
Example #11
0
        public void PropertyValueAccessorGetInt32Test()
        {
            // Arrange
            PropertyInfo propertyInfo  = typeof(EntityWithProperties).GetProperty("Int32");
            var          valueAccessor = new PropertyValueAccessor <EntityWithProperties>(propertyInfo);
            const Int32  value         = 3;
            var          user          = new EntityWithProperties {
                Int32 = value
            };

            // Act
            EntityProperty entityProperty = valueAccessor.GetValue(user);

            // Assert
            Assert.Equal(entityProperty.Int32Value, value);
        }
Example #12
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);
        }
Example #13
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);
        }
Example #14
0
        public void PropertyValueAccessorGetDoubleTest()
        {
            // Arrange
            PropertyInfo propertyInfo  = typeof(EntityWithProperties).GetProperty("Double");
            var          valueAccessor = new PropertyValueAccessor <EntityWithProperties>(propertyInfo);
            const Double value         = 0.3;
            var          user          = new EntityWithProperties {
                Double = value
            };

            // Act
            EntityProperty entityProperty = valueAccessor.GetValue(user);

            // Assert
            Assert.Equal(entityProperty.DoubleValue, value);
        }
Example #15
0
        public void PropertyValueAccessorGetNullableDateTimeOffsetTest()
        {
            // Arrange
            PropertyInfo   propertyInfo  = typeof(EntityWithProperties).GetProperty("NullableDateTimeOffset");
            var            valueAccessor = new PropertyValueAccessor <EntityWithProperties>(propertyInfo);
            DateTimeOffset?value         = DateTime.UtcNow;
            var            user          = new EntityWithProperties {
                NullableDateTimeOffset = value
            };

            // Act
            EntityProperty entityProperty = valueAccessor.GetValue(user);

            // Assert
            Assert.Equal(entityProperty.DateTimeOffsetValue, value);
        }
Example #16
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);
        }
Example #17
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);
        }
Example #18
0
        public void PropertyValueAccessorGetBinaryTest()
        {
            // Arrange
            PropertyInfo propertyInfo  = typeof(EntityWithProperties).GetProperty("Binary");
            var          valueAccessor = new PropertyValueAccessor <EntityWithProperties>(propertyInfo);
            var          value         = new byte[] { 0x11, 0x22, 0x33 };
            var          user          = new EntityWithProperties {
                Binary = value
            };

            // Act
            EntityProperty entityProperty = valueAccessor.GetValue(user);

            // Assert
            Assert.Equal(entityProperty.BinaryValue, value);
        }
Example #19
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);
        }
Example #20
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);
        }
Example #21
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);
        }
Example #22
0
        public void PropertyValueAccessorGetDateTimeTest()
        {
            // Arrange
            PropertyInfo propertyInfo  = typeof(EntityWithProperties).GetProperty("DateTime");
            var          valueAccessor = new PropertyValueAccessor <EntityWithProperties>(propertyInfo);
            DateTime     value         = DateTime.UtcNow;
            var          user          = new EntityWithProperties {
                DateTime = value
            };

            // Act
            EntityProperty entityProperty = valueAccessor.GetValue(user);

            // Assert
            Assert.NotNull(entityProperty.DateTimeOffsetValue);
            Assert.True(entityProperty.DateTimeOffsetValue.HasValue);
            Assert.Equal(entityProperty.DateTimeOffsetValue.Value.DateTime, value);
        }