예제 #1
0
파일: DetoursTests.cs 프로젝트: zhouzu/Juno
        public void TestInitialiseDetour()
        {
            _methodDetour.InitialiseDetour();

            Assert.Equal(50, _testClass.TestMethod(_testVariable1, _testVariable2));

            _methodDetour.RemoveDetour();
        }
예제 #2
0
        public void TestAddDetour()
        {
            // Add the detour

            _functionDetour.AddDetour();

            Assert.Equal(50, _testClass.TestMethod(_testVariable1, _testVariable2));

            // Remove the detour

            _functionDetour.RemoveDetour();
        }
예제 #3
0
        public void TestAddDetourWithMethodInfo()
        {
            var originalMethodInfo = typeof(TestClass1).GetMethod("TestMethod", BindingFlags.FlattenHierarchy | BindingFlags.Instance | BindingFlags.Public);

            var targetMethodInfo = typeof(TestClass2).GetMethod("TestMethod", BindingFlags.FlattenHierarchy | BindingFlags.Instance | BindingFlags.Public);

            // Initialise a function detour

            var functionDetour = new FunctionDetour(originalMethodInfo, targetMethodInfo);

            // Initialize a test class

            var testClass1 = new TestClass1();

            functionDetour.AddDetour();

            Assert.Equal(2, testClass1.TestMethod(1, 2));

            functionDetour.RemoveDetour();
        }