public void When_exception_occurs_during_invocation__preloaded_and_reflected_implementations_behave_the_same()
        {
            var preloaded = type.of <TestClass_OOP>().GetProperty("ExceptionProperty");
            var reflected = type.of <TestOuterDomainType_OOP>().GetProperty("ExceptionProperty");

            Assert.IsInstanceOf <PreloadedPropertyInfo>(preloaded);
            Assert.IsInstanceOf <ReflectedPropertyInfo>(reflected);

            var expectedException = new Exception("expected");

            var testSubject1 = new TestClass_OOP
            {
                Exception = expectedException
            };

            try
            {
                preloaded.GetValue(testSubject1);
                Assert.Fail("exception not thrown");
            }
            catch (Exception ex)
            {
                Assert.AreSame(expectedException, ex);
            }

            try
            {
                preloaded.SetValue(testSubject1, string.Empty);
                Assert.Fail("exception not thrown");
            }
            catch (Exception ex)
            {
                Assert.AreSame(expectedException, ex);
            }

            var testSubject2 = new TestOuterDomainType_OOP
            {
                Exception = expectedException
            };

            try
            {
                reflected.GetValue(testSubject2);
                Assert.Fail("exception not thrown");
            }
            catch (Exception ex)
            {
                Assert.AreSame(expectedException, ex);
            }

            try
            {
                reflected.SetValue(testSubject2, string.Empty);
                Assert.Fail("exception not thrown");
            }
            catch (Exception ex)
            {
                Assert.AreSame(expectedException, ex);
            }
        }
        public void Routine_PropertyInfo_can_set_value()
        {
            var obj = new TestClass_OOP();

            testing.SetValue(obj, "expected_set");

            Assert.AreEqual("expected_set", obj.PublicProperty);
        }
Example #3
0
        public void Routine_MethodInfo_can_invoke_default_interface_methods()
        {
            testing = OOP_InterfaceMethod("DefaultInterfaceMethod");

            var obj = new TestClass_OOP();

            Assert.AreEqual("default interface test", testing.Invoke(obj, "test"));
        }
Example #4
0
        public void Routine_MethodInfo_can_invoke_instance_methods()
        {
            testing = OOP_Method("PublicPingMethod");

            var obj = new TestClass_OOP();

            Assert.AreEqual("instance test", testing.Invoke(obj, "test"));
        }
        public void Routine_PropertyInfo_can_get_value()
        {
            var obj = new TestClass_OOP
            {
                PublicProperty = "expected_get"
            };

            Assert.AreEqual("expected_get", testing.GetValue(obj));
        }