예제 #1
0
        public void ReadOnlyGet()
        {
            TestClass testClass = new TestClass();
            DynamicProperty <TestClass> nameProperty = DynamicType <TestClass> .CreateDynamicProperty("ReadOnlyName");

            Assert.AreEqual("SomeTestName", nameProperty.InvokeGetterOn(testClass));
        }
예제 #2
0
        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);
        }
예제 #3
0
        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);
        }
예제 #4
0
        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);
        }
예제 #5
0
        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));
        }
예제 #6
0
        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));
        }