public void Invoke_ValidObject_ValidValue() { // Arrange var reflection = ReflectionCache.GetReflection(typeof(ExampleObject)).Methods["TestMethod"][1]; ExampleObject obj = new ExampleObject(); // Act reflection.Invoke(obj, 3); // Assert Assert.AreEqual(3, obj.Property1); }
public void GetValue_NoSetter_NoSuchMethodException() { // Arrange var reflection = ReflectionCache.GetReflection(typeof(ExampleObject)).Properties["Property3"]; ExampleObject obj = new ExampleObject(); // Act NoSuchMethodReflectionException e = null; try { reflection.GetValue(obj); } catch (NoSuchMethodReflectionException ex) { e = ex; } // Assert Assert.IsNotNull(e); }
public void GetValue_ValidObject_ValidValue() { // Arrange var reflection = ReflectionCache.GetReflection(typeof(ExampleObject)).Properties["Property4"]; ExampleObject obj = new ExampleObject(); // Act var result = reflection.GetValue(obj); // Assert Assert.AreEqual(obj, result); }
public void SetValue_ValidObject_ValidValue() { // Arrange var reflection = ReflectionCache.GetReflection(typeof(ExampleObject)).Properties["Property2"]; ExampleObject obj = new ExampleObject(); // Act reflection.SetValue(obj, "test string"); // Assert Assert.AreEqual("test string", obj.Property2); }