Ejemplo n.º 1
0
        public void UpdatePropertyValue_ShouldUpdateValue_WhenPropertyFound(string propertyName, object value)
        {
            var testClass = new TestClass();
            var propertyInfo = typeof(TestClass).GetProperties()
                .First(x => x.Name == propertyName);
            testClass.UpdatePropertyValue(propertyName, value);

            Assert.AreEqual(value, propertyInfo.GetValue(testClass));
        }
Ejemplo n.º 2
0
        public void UpdatePropertyValue_ShouldDeserializeAndUpdateValue_WhenPropertyFound(string propertyName, object value, object expected)
        {
            _serializationMock.Setup(x => x.FromJson(value.ToString(), expected.GetType()))
                .Returns(expected);

            var testClass = new TestClass();
            var propertyInfo = typeof(TestClass).GetProperties()
                .First(x => x.Name == propertyName);
            testClass.UpdatePropertyValue(propertyName, value, _serializationMock.Object);

            Assert.AreEqual(expected, propertyInfo.GetValue(testClass));
        }