コード例 #1
0
        public void Get_WhenGivenObject_ReturnsReflectiveType()
        {
            var cache = new ReflectiveCache();

            var basicObject = new { DataItemID = 1, DataItemCurrentStatusID = 1, DataItemStatusID = 1, DateEffective = DateTime.Now };

            var result = cache.Get(basicObject);

            Assert.AreEqual(typeof(ReflectiveType), result.GetType());
        }
コード例 #2
0
        public void SetValue_WhenCalled_SetsProperty()
        {
            var cache       = new ReflectiveCache();
            var basicObject = new DataStatusItem {
                DataItemID = 1, DataItemCurrentStatusID = 1, DataItemStatusID = 1, DateEffective = DateTime.Now
            };
            var type = cache.Get(basicObject);

            var prop = type.GetProperties().Where(x => x.Name == nameof(DataStatusItem.DataItemID)).First();

            prop.SetValue(basicObject, 2);

            Assert.AreEqual(2, basicObject.DataItemID);
        }