예제 #1
0
        public void Test_Method8()
        {
            var originalClass = typeof(Class8);

            Assert.NotNull(originalClass);
            var originalMethod = originalClass.GetMethod("Method8");

            Assert.NotNull(originalMethod);

            var patchClass = typeof(Class8Patch);
            var postfix    = patchClass.GetMethod("Postfix");

            Assert.NotNull(postfix);

            var instance = new Harmony("test");

            Assert.NotNull(instance);

            var patcher = instance.CreateProcessor(originalMethod);

            Assert.NotNull(patcher);
            _ = patcher.AddPostfix(postfix);
            Assert.NotNull(patcher);

            _ = patcher.Patch();

            var result = Class8.Method8("patched");

            Assert.True(Class8.mainRun);
            Assert.AreEqual(10, result.a);
            Assert.AreEqual(20, result.b);
        }
예제 #2
0
파일: Arguments.cs 프로젝트: msvenm/Harmony
        public void TestMethod8()
        {
            var originalClass = typeof(Class8);

            Assert.IsNotNull(originalClass);
            var originalMethod = originalClass.GetMethod("Method8");

            Assert.IsNotNull(originalMethod);

            var patchClass = typeof(Class8Patch);
            var postfix    = patchClass.GetMethod("Postfix");

            Assert.IsNotNull(postfix);

            var instance = HarmonyInstance.Create("test");

            Assert.IsNotNull(instance);

            var patcher = new PatchProcessor(instance, new List <MethodBase> {
                originalMethod
            }, null, new HarmonyMethod(postfix));

            Assert.IsNotNull(patcher);

            patcher.Patch();

            var result = Class8.Method8("patched");

            Assert.IsTrue(Class8.mainRun);
            Assert.AreEqual(10, result.a);
            Assert.AreEqual(20, result.b);
        }