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

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

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

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

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

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

            Assert.AreEqual(77, result);
        }
Exemple #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);
        }
Exemple #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);
        }
Exemple #9
0
        public void WriteViaReflection_SetsPropertyValue()
        {
            var instance = new TestReflectionClass1();

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

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

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

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

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

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

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