public void FieldValueAccessorSetBooleanTest()
        {
            // Arrange
            FieldInfo fieldInfo = typeof(EntityWithFields).GetField("Boolean");
            var valueAccessor = new FieldValueAccessor<EntityWithFields>(fieldInfo);
            var entity = new EntityWithFields {Boolean = true};
            const bool newValue = false;

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

            // Assert
            Assert.Equal(entity.Boolean, newValue);
        }
Beispiel #2
0
        public void FieldValueAccessorSetBinaryTest()
        {
            // Arrange
            FieldInfo fieldInfo     = typeof(EntityWithFields).GetField("Binary");
            var       valueAccessor = new FieldValueAccessor <EntityWithFields>(fieldInfo);
            var       entity        = new EntityWithFields {
                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);
        }
Beispiel #3
0
        public void FieldValueAccessorSetNullableBooleanTest()
        {
            // Arrange
            FieldInfo fieldInfo     = typeof(EntityWithFields).GetField("NullableBoolean");
            var       valueAccessor = new FieldValueAccessor <EntityWithFields>(fieldInfo);
            var       entity        = new EntityWithFields {
                NullableBoolean = true
            };
            const bool newValue = false;

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

            // Assert
            Assert.Equal(entity.NullableBoolean, newValue);
        }
Beispiel #4
0
        public void FieldValueAccessorSetStringTest()
        {
            // Arrange
            FieldInfo fieldInfo     = typeof(EntityWithFields).GetField("String");
            var       valueAccessor = new FieldValueAccessor <EntityWithFields>(fieldInfo);
            var       entity        = new EntityWithFields {
                String = "aabbcc"
            };
            const string newValue = "ccbbaa";

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

            // Assert
            Assert.Equal(entity.String, newValue);
        }
Beispiel #5
0
        public void FieldValueAccessorSetInt64Test()
        {
            // Arrange
            FieldInfo fieldInfo     = typeof(EntityWithFields).GetField("Int64");
            var       valueAccessor = new FieldValueAccessor <EntityWithFields>(fieldInfo);
            var       entity        = new EntityWithFields {
                Int64 = 2
            };
            const Int64 newValue = 5;

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

            // Assert
            Assert.Equal(entity.Int64, newValue);
        }
Beispiel #6
0
        public void FieldValueAccessorSetNullableInt64Test()
        {
            // Arrange
            FieldInfo fieldInfo     = typeof(EntityWithFields).GetField("NullableInt64");
            var       valueAccessor = new FieldValueAccessor <EntityWithFields>(fieldInfo);
            var       entity        = new EntityWithFields {
                NullableInt64 = null
            };
            Int64?newValue = 5;

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

            // Assert
            Assert.Equal(entity.NullableInt64, newValue);
        }
Beispiel #7
0
        public void FieldValueAccessorSetNullableDoubleTest()
        {
            // Arrange
            FieldInfo fieldInfo     = typeof(EntityWithFields).GetField("NullableDouble");
            var       valueAccessor = new FieldValueAccessor <EntityWithFields>(fieldInfo);
            var       entity        = new EntityWithFields {
                NullableDouble = 0.3
            };
            Double?newValue = 0.5;

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

            // Assert
            Assert.Equal(entity.NullableDouble, newValue);
        }
Beispiel #8
0
        public void FieldValueAccessorSetNullableGuidTest()
        {
            // Arrange
            FieldInfo fieldInfo     = typeof(EntityWithFields).GetField("NullableGuid");
            var       valueAccessor = new FieldValueAccessor <EntityWithFields>(fieldInfo);
            var       entity        = new EntityWithFields {
                NullableGuid = null
            };
            Guid?newValue = Guid.NewGuid();

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

            // Assert
            Assert.Equal(entity.NullableGuid, newValue);
        }
Beispiel #9
0
        public void FieldValueAccessorSetDateTimeOffsetTest()
        {
            // Arrange
            FieldInfo fieldInfo     = typeof(EntityWithFields).GetField("DateTimeOffset");
            var       valueAccessor = new FieldValueAccessor <EntityWithFields>(fieldInfo);
            var       entity        = new EntityWithFields {
                DateTimeOffset = DateTime.Today
            };
            DateTimeOffset newValue = DateTime.Now;

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

            // Assert
            Assert.Equal(entity.DateTimeOffset, newValue);
        }
Beispiel #10
0
        public void FieldValueAccessorSetNullableDateTimeOffsetTest()
        {
            // Arrange
            FieldInfo fieldInfo     = typeof(EntityWithFields).GetField("NullableDateTimeOffset");
            var       valueAccessor = new FieldValueAccessor <EntityWithFields>(fieldInfo);
            var       entity        = new EntityWithFields {
                NullableDateTimeOffset = null
            };
            DateTimeOffset?newValue = DateTime.UtcNow;

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

            // Assert
            Assert.Equal(entity.NullableDateTimeOffset, newValue);
        }
        public void FieldValueAccessorSetBinaryTest()
        {
            // Arrange
            FieldInfo fieldInfo = typeof(EntityWithFields).GetField("Binary");
            var valueAccessor = new FieldValueAccessor<EntityWithFields>(fieldInfo);
            var entity = new EntityWithFields { 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 FieldValueAccessorSetStringTest()
        {
            // Arrange
            FieldInfo fieldInfo = typeof(EntityWithFields).GetField("String");
            var valueAccessor = new FieldValueAccessor<EntityWithFields>(fieldInfo);
            var entity = new EntityWithFields { String = "aabbcc" };
            const string newValue = "ccbbaa";

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

            // Assert
            Assert.Equal(entity.String, newValue);
        }
        public void FieldValueAccessorSetDateTimeOffsetTest()
        {
            // Arrange
            FieldInfo fieldInfo = typeof(EntityWithFields).GetField("DateTimeOffset");
            var valueAccessor = new FieldValueAccessor<EntityWithFields>(fieldInfo);
            var entity = new EntityWithFields { DateTimeOffset = DateTime.Today };
            DateTimeOffset newValue = DateTime.Now;

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

            // Assert
            Assert.Equal(entity.DateTimeOffset, newValue);
        }
        public void FieldValueAccessorSetNullableInt64Test()
        {
            // Arrange
            FieldInfo fieldInfo = typeof(EntityWithFields).GetField("NullableInt64");
            var valueAccessor = new FieldValueAccessor<EntityWithFields>(fieldInfo);
            var entity = new EntityWithFields { NullableInt64 = null };
            Int64? newValue = 5;

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

            // Assert
            Assert.Equal(entity.NullableInt64, newValue);
        }
        public void FieldValueAccessorSetNullableDateTimeOffsetTest()
        {
            // Arrange
            FieldInfo fieldInfo = typeof(EntityWithFields).GetField("NullableDateTimeOffset");
            var valueAccessor = new FieldValueAccessor<EntityWithFields>(fieldInfo);
            var entity = new EntityWithFields { NullableDateTimeOffset = null };
            DateTimeOffset? newValue = DateTime.UtcNow;

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

            // Assert
            Assert.Equal(entity.NullableDateTimeOffset, newValue);
        }
        public void FieldValueAccessorSetInt64Test()
        {
            // Arrange
            FieldInfo fieldInfo = typeof(EntityWithFields).GetField("Int64");
            var valueAccessor = new FieldValueAccessor<EntityWithFields>(fieldInfo);
            var entity = new EntityWithFields { Int64 = 2 };
            const Int64 newValue = 5;

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

            // Assert
            Assert.Equal(entity.Int64, newValue);
        }
        public void FieldValueAccessorSetNullableGuidTest()
        {
            // Arrange
            FieldInfo fieldInfo = typeof(EntityWithFields).GetField("NullableGuid");
            var valueAccessor = new FieldValueAccessor<EntityWithFields>(fieldInfo);
            var entity = new EntityWithFields { NullableGuid = null };
            Guid? newValue = Guid.NewGuid();

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

            // Assert
            Assert.Equal(entity.NullableGuid, newValue);
        }
        public void FieldValueAccessorSetNullableDoubleTest()
        {
            // Arrange
            FieldInfo fieldInfo = typeof(EntityWithFields).GetField("NullableDouble");
            var valueAccessor = new FieldValueAccessor<EntityWithFields>(fieldInfo);
            var entity = new EntityWithFields { NullableDouble = 0.3 };
            Double? newValue = 0.5;

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

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