public void AssignDoubleToString()
        {
            const double value = 7.78;

            // Arrange
            var obj = new SomeHiddenPropertyClass();
            IBindingResolver reflectionResolver = new ReflectionResolver(nameof(SomeClass.SimpleString));

            // Act
            var result = reflectionResolver.Update(obj, value);

            // Assert
            Assert.IsTrue(result);
            Assert.AreEqual(value, Convert.ToDouble(obj.SimpleString));
        }
Esempio n. 2
0
        public void SimpleAssign()
        {
            const string str = "HelloWorld";

            // Arrange
            var obj = new SomeHiddenPropertyClass();
            IBindingResolver reflectionResolver = new ReflectionResolver(nameof(SomeClass.SimpleString));

            // Act
            var result = reflectionResolver.Update(obj, str);

            // Assert
            Assert.IsTrue(result);
            Assert.AreEqual(str, obj.SimpleString);
        }
        public void AssignStringToInt()
        {
            const string number = "5";

            // Arrange
            var obj = new SomeHiddenPropertyClass();
            IBindingResolver reflectionResolver = new ReflectionResolver(nameof(SomeClass.SimpleInt));

            // Act
            var result = reflectionResolver.Update(obj, number);

            // Assert
            Assert.IsTrue(result);
            Assert.AreEqual(int.Parse(number), obj.SimpleInt);
        }
Esempio n. 4
0
        public void HiddenPropertyByNewKeyword()
        {
            // Arrange
            IBindingResolver reflectionResolver = new ReflectionResolver(nameof(SomeClass.SomeObject));
            var obj = new SomeHiddenPropertyClass
            {
                SomeObject = new SomeImplementation()
            };

            // Act
            // Should resolve the value of SomeObject
            object result = null;

            Assert.DoesNotThrow(delegate
            {
                result = reflectionResolver.Resolve(obj);
            });

            // Assert
            Assert.NotNull(result);
        }