Esempio n. 1
0
        public void GetFieldValue()
        {
            var mock = new ReflectionMock();
            var res  = mock.ByReflection().GetField <int>("_fieldValue");

            res.ShouldBe(100);
        }
Esempio n. 2
0
        public void GetPrivatePropertyValue()
        {
            var mock = new ReflectionMock();
            var res  = mock.ByReflection().GetProperty <int>("PrivateProperty", BindingFlags.NonPublic | BindingFlags.Instance);

            res.ShouldBe(3);
        }
Esempio n. 3
0
        public void GetPublicPropertyValue()
        {
            var mock = new ReflectionMock();
            var res  = mock.ByReflection().GetProperty <int>(nameof(ReflectionMock.PublicProperty));

            res.ShouldBe(2);
        }
Esempio n. 4
0
        public void SetPublicPropertyValue()
        {
            var mock = new ReflectionMock();

            mock.ByReflection().SetProperty <int>(nameof(ReflectionMock.PublicProperty), 10);

            mock.PublicProperty.ShouldBe(10);
        }
Esempio n. 5
0
        public void InvokePrivateMethodWithReturn()
        {
            var mock = new ReflectionMock();
            var res  = mock.ByReflection().InvokeMethod <int>("PrivateMethodWithReturn", BindingFlags.NonPublic | BindingFlags.Instance);

            res.ShouldBe(1);
            mock.PrivateMethodWithReturnInvoked.ShouldBeTrue();
        }
Esempio n. 6
0
        public void InvokePrivateVoidMethod()
        {
            var mock = new ReflectionMock();

            mock.ByReflection().InvokeMethod("PrivateMethod", BindingFlags.NonPublic | BindingFlags.Instance);

            mock.PrivateInvoked.ShouldBeTrue();
        }
Esempio n. 7
0
        public void InvokeMethodWithReturn()
        {
            var mock = new ReflectionMock();
            var res  = mock.ByReflection().InvokeMethod <int>(nameof(ReflectionMock.PublicMethodWithReturn));

            res.ShouldBe(1);
            mock.PublicMethodWithReturnInvoked.ShouldBeTrue();
        }
Esempio n. 8
0
        public void InvokePublicVoidMethod()
        {
            var mock = new ReflectionMock();

            mock.ByReflection().InvokeMethod(nameof(ReflectionMock.PublicMethod));

            mock.PublicInvoked.ShouldBeTrue();
        }