public void ReadOnlyGet() { TestClass testClass = new TestClass(); DynamicProperty <TestClass> nameProperty = DynamicType <TestClass> .CreateDynamicProperty("ReadOnlyName"); Assert.AreEqual("SomeTestName", nameProperty.InvokeGetterOn(testClass)); }
public void ReadOnlyInstantiation() { DynamicProperty <TestClass> nameProperty = DynamicType <TestClass> .CreateDynamicProperty("ReadOnlyName"); Assert.AreEqual("ReadOnlyName", nameProperty.AttributeName); Assert.AreEqual(typeof(string), nameProperty.Type); Assert.IsFalse(nameProperty.HasSetter); Assert.IsTrue(nameProperty.HasGetter); }
public void RaiseExceptionReadOnlySet() { TestClass testClass = new TestClass(); DynamicProperty <TestClass> nameProperty = DynamicType <TestClass> .CreateDynamicProperty("ReadOnlyName"); Assert.AreEqual("SomeTestName", testClass.Name); nameProperty.InvokeSetterOn(testClass, "Colossus"); Assert.AreEqual("Colossus", testClass.Name); }
public void Set() { DynamicProperty <TestClass> nameProperty = DynamicType <TestClass> .CreateDynamicProperty("Name"); TestClass testClass = new TestClass(); Assert.AreEqual("SomeTestName", testClass.Name); nameProperty.InvokeSetterOn(testClass, "Colossus"); Assert.AreEqual("Colossus", testClass.Name); }
public void GetAndSetObjectType() { TestClass testClass = new TestClass(); DynamicProperty <TestClass> nameProperty = DynamicType <TestClass> .CreateDynamicProperty("Name"); Assert.AreEqual("SomeTestName", nameProperty.InvokeGetterOn(testClass)); nameProperty.InvokeSetterOn(testClass, "Colossus"); Assert.AreEqual("Colossus", nameProperty.InvokeGetterOn(testClass)); }
public void SetPropertiesAsObject3(string propertyName, object propertyValue) { DynamicProperty <WorkOrder> property = DynamicType <WorkOrder> .CreateDynamicProperty(propertyName); WorkOrder testClass = new WorkOrder(); property.InvokeSetterOn(testClass, propertyValue); Assert.AreEqual((ScrapReason)(short)propertyValue, property.InvokeGetterOn(testClass)); }