public void InvokeMethodWithDerivedParametersTest() { var accessor = DynamicObjectAccessor.Create(new TestClass(), true); var value = (string)accessor.GetObjectString(12345); Assert.AreEqual("12345", value); }
public void InvokeMethodWithGenericsTest() { var accessor = DynamicObjectAccessor.Create(new TestClass(), true); var value = (int)accessor.GenericMethod <int>(1); Assert.AreEqual(1, value); }
public void InvokePrivateMethodTest() { var accessor = DynamicObjectAccessor.Create(new TestClass(), true); var value = (string)accessor.PrivateMethod(); Assert.AreEqual(DefaultMethodStringValue, value); }
public void InvokeMethodWithParametersTest() { var accessor = DynamicObjectAccessor.Create(new TestClass(), true); var value = (int)accessor.AddMethod(1, 2); Assert.AreEqual(3, value); }
public void GetThenInvokePublicMethodTest() { var accessor = DynamicObjectAccessor.Create(new TestClass(), true); var method = accessor.PublicMethod; var value = (string)method(); Assert.AreEqual(DefaultMethodStringValue, value); }
public void InvokeHiddenMethodTest() { // This should only invoke the first method going down the types var accessor = DynamicObjectAccessor.Create(new TestClass(), true); var value = (string)accessor.HiddenMethod(); Assert.AreEqual(DefaultMethodStringValue, value); }
public void CastReturnToConvertableTypeTest() { var accessor = DynamicObjectAccessor.Create(new TestClass(), true); var publicField = accessor.PublicTestInt; var publicFieldValue = (long)publicField; Assert.IsNotNull(publicFieldValue); }
public void AccessPrivateFieldTest() { var accessor = DynamicObjectAccessor.Create(new TestClass(), true); var privateField = accessor.PrivateField; var privateFieldValue = (string)privateField; Assert.IsNotNull(privateField); Assert.AreEqual(PrivateFieldStringValue, privateFieldValue); }
public void GetByMultiIndexTest() { var accessor = DynamicObjectAccessor.Create(new TestClass(), true); var privateClassField = accessor["PublicTestObject", "PrivateClassString"]; var privateClassFieldValue = (string)privateClassField; Assert.IsNotNull(privateClassField); Assert.AreEqual(PrivateFieldStringValue, privateClassFieldValue); }
public void GetByIndexTest() { var accessor = DynamicObjectAccessor.Create(new TestClass(), true); var publicField = accessor["PublicTestObject"]; var publicFieldValue = (AccessorMemberTests.A)publicField; Assert.IsNotNull(publicFieldValue); Assert.IsTrue(publicFieldValue is AccessorMemberTests.A); }
public void CastReturnToBaseTypeTest() { var accessor = DynamicObjectAccessor.Create(new TestClass(), true); var publicField = accessor.PublicTestObject; var publicFieldValue = (AccessorMemberTests.A)publicField; Assert.IsNotNull(publicFieldValue); Assert.IsTrue(publicFieldValue is AccessorMemberTests.A); }
public void AccessPublicPropertyTest() { var accessor = DynamicObjectAccessor.Create(new TestClass(), true); var publicProperty = accessor.PublicProperty; var publicPropertyValue = (string)publicProperty; Assert.IsNotNull(publicProperty); Assert.AreEqual(PublicPropertyStringValue, publicPropertyValue); }
public void AccessPrivateFieldOnBaseClassTest() { var accessor = DynamicObjectAccessor.Create(new B(), true); var privateBaseClassProperty = accessor.PrivateBaseClassString; var privateBaseClassPropertyValue = (string)privateBaseClassProperty; Assert.IsNotNull(privateBaseClassProperty); Assert.AreEqual(PrivateFieldStringValue, privateBaseClassPropertyValue); }
public void TestPropertyNullAssigning() { var accessor = DynamicObjectAccessor.Create(new TestClass(), true); accessor.TestProperty = null; var newPropertyValue = (string)accessor.TestProperty; Assert.AreEqual(null, newPropertyValue); }
public void TestFieldNullAssigning() { var accessor = DynamicObjectAccessor.Create(new TestClass(), true); accessor.TestField = null; var newFieldValue = (string)accessor.TestField; Assert.AreEqual(null, newFieldValue); }
public void SetByMultiIndexTest() { var accessor = DynamicObjectAccessor.Create(new TestClass(), true); accessor["Child", "PublicStringField"] = TestStringValue; var newFieldValue = (string)accessor.Child.PublicStringField; Assert.AreEqual(TestStringValue, newFieldValue); }
public void AccessHiddenFieldTest() { var accessor = DynamicObjectAccessor.Create(new B(), true); var accessorHidden = DynamicObjectAccessor.Create(new B(), true, typeof(A)); var privateFieldValue = (string)accessor.HiddenStringField; var hiddenPrivateFieldValue = (string)accessorHidden.HiddenStringField; Assert.AreEqual(privateFieldValue, string.Empty); Assert.AreEqual(hiddenPrivateFieldValue, PrivateFieldStringValue); }
public void TestThrowOnInvalidTypeAssign() { var accessor = DynamicObjectAccessor.Create(new TestClass(), true); Assert.ThrowsException <RuntimeBinderException>(() => accessor.TestField = 42); }
public void CastReturnToInvalidTypeTest() { var accessor = DynamicObjectAccessor.Create(new TestClass(), true); Assert.ThrowsException <RuntimeBinderException>(() => (int)accessor.PublicField); }
public void AccessInvalidIndexTest() { var accessor = DynamicObjectAccessor.Create(new TestClass(), true); Assert.ThrowsException <RuntimeBinderException>(() => accessor["PropertyThatDoesNotExist"]); }
public void AccessUsingInvalidIndexType() { var accessor = DynamicObjectAccessor.Create(new TestClass(), true); Assert.ThrowsException <RuntimeBinderException>(() => accessor[42]); }
public void InvokeMethodWithInvalidParametersTest() { var accessor = DynamicObjectAccessor.Create(new TestClass(), true); Assert.ThrowsException <RuntimeBinderException>(() => accessor.AddMethod("1", "2")); }
public void AccessStaticFieldTest() { var accessor = DynamicObjectAccessor.Create(new TestClass(), true); Assert.ThrowsException <RuntimeBinderException>(() => accessor.StaticField); }
public void TestThrowOnGetProperty() { var accessor = DynamicObjectAccessor.Create(new TestClass(), true); Assert.ThrowsException <RuntimeBinderException>(() => accessor.TestGetOnlyProperty = TestStringValue); }
public void TestThrowOnNullAssignOnvalueType() { var accessor = DynamicObjectAccessor.Create(new TestClass(), true); Assert.ThrowsException <RuntimeBinderException>(() => accessor.TestValueField = null); }
public void AccessNonExistentMemberTest() { var accessor = DynamicObjectAccessor.Create(new TestClass(), true); Assert.ThrowsException <RuntimeBinderException>(() => accessor.SomeMemebrThatDoesNotExist); }