Beispiel #1
0
        public void InvokeMethodWithNonNullParametersViaReflection_PropagatesNullReferenceExceptionNullParameter()
        {
            var instance = new TestReflectionClass1();

            ExceptionAssert.Propagates <NullReferenceException>(() =>
                                                                instance.InvokeMethodWithNonNullParametersViaReflection("PublicMethodWithIntParameter", new object[] { null }));
        }
Beispiel #2
0
        public void InvokeMethodWithNonNullParametersViaReflection_IsResult()
        {
            var instance = new TestReflectionClass1();
            var result   = instance.InvokeMethodWithNonNullParametersViaReflection("PublicMethodWithIntParameter", 99);

            Assert.AreEqual(99, result);
        }
Beispiel #3
0
        public void InvokeMethodWithNonNullParametersViaReflection_CallsMethod()
        {
            var instance = new TestReflectionClass1();

            instance.InvokeMethodWithNonNullParametersViaReflection("PublicParameterlessMethod");
            Assert.IsTrue(instance.PublicParameterlessMethodCalled);
        }
Beispiel #4
0
        public void InvokeMethodWithNonNullParametersViaReflection_PassesParameters()
        {
            var instance = new TestReflectionClass1();

            instance.InvokeMethodWithNonNullParametersViaReflection("PublicMethodWithIntParameter", 88);
            Assert.AreEqual(88, instance.PublicMethodWithIntParameterData);
        }
Beispiel #5
0
        public void InvokeMethodViaReflection_WithoutTypes_PassesParameters()
        {
            var instance = new TestReflectionClass1();

            instance.InvokeMethodViaReflection("PublicMethodWithIntParameter", 66);
            Assert.AreEqual(66, instance.PublicMethodWithIntParameterData);
        }
Beispiel #6
0
        public void InvokeMethodViaReflection_WithoutTypes_IsResult()
        {
            var instance = new TestReflectionClass1();
            var result   = instance.InvokeMethodViaReflection("PublicMethodWithIntParameter", 77);

            Assert.AreEqual(77, result);
        }
Beispiel #7
0
        public void InvokeMethodViaReflection_WithTypes_PassesParameters()
        {
            var instance = new TestReflectionClass1();

            instance.InvokeMethodViaReflection("PublicMethodWithIntParameter", new[] { typeof(int) }, new object[] { 101 });
            Assert.AreEqual(101, instance.PublicMethodWithIntParameterData);
        }
Beispiel #8
0
        public void InvokeMethodViaReflection_WithTypes_IsResult()
        {
            var instance = new TestReflectionClass1();
            var result   = instance.InvokeMethodViaReflection("PublicMethodWithIntParameter", new[] { typeof(int) }, new object[] { 45 });

            Assert.AreEqual(45, result);
        }
Beispiel #9
0
        public void WriteViaReflection_SetsPropertyValue()
        {
            var instance = new TestReflectionClass1();

            instance.WriteViaReflection("PublicProperty", 28);
            Assert.AreEqual(28, instance.PublicProperty);
        }
Beispiel #10
0
        public void InvokeMethodViaReflection_WithTypes_CallsMethod()
        {
            var instance = new TestReflectionClass1();

            instance.InvokeMethodViaReflection("PublicParameterlessMethod", new Type[0], new object[0]);
            Assert.IsTrue(instance.PublicParameterlessMethodCalled);
        }
Beispiel #11
0
        public void WriteViaReflection_SetsFieldValue()
        {
            var instance = new TestReflectionClass1();

            instance.WriteViaReflection("PublicField", 18);
            Assert.AreEqual(18, instance.PublicField);
        }
Beispiel #12
0
        public void WriteIndexerViaReflection_SetsIndexerValue()
        {
            var instance = new TestReflectionClass1();

            instance.IndexedValue = new int[1];
            instance.WriteIndexerViaReflection(8, 0);
            Assert.AreEqual(8, instance[0]);
        }
Beispiel #13
0
        public void ReadIndexeViaReflectionr_IsIndexerValue()
        {
            var instance = new TestReflectionClass1();

            instance.IndexedValue = new int[1];
            instance[0]           = 101;
            Assert.AreEqual(101, instance.ReadIndexerViaReflection(0));
        }
Beispiel #14
0
        public void ReadViaReflection_IsPropertyValue()
        {
            var instance = new TestReflectionClass1 {
                PublicProperty = 6
            };

            Assert.AreEqual(6, instance.ReadViaReflection("PublicProperty"));
        }
Beispiel #15
0
        public void ReadViaReflection_IsFieldValue()
        {
            var instance = new TestReflectionClass1 {
                PublicField = 5
            };

            Assert.AreEqual(5, instance.ReadViaReflection("PublicField"));
        }