Exemplo n.º 1
0
        public DetoursTests()
        {
            _methodDetour = new MethodDetour <TestClass1, TestClass2>("TestMethod", "TestMethod");

            _testClass = new TestClass1();

            _testVariable1 = 5;

            _testVariable2 = 10;
        }
Exemplo n.º 2
0
        public DetourTests()
        {
            // Initialize a function detour instance

            _functionDetour = new FunctionDetour(typeof(TestClass1), "TestMethod", typeof(TestClass2), "TestMethod");

            // Initialize a test class

            _testClass = new TestClass1();

            // Initialise test variables

            _testVariable1 = 5;

            _testVariable2 = 10;
        }
Exemplo n.º 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();
        }