public void TestTypeWithDependencies()
        {
            var callback    = new NpcFeatherCallback();
            var featherImpl = new NpcInjectionRunner(this.assembly.MainModule, callback);
            var type        = this.assembly.MainModule.GetType("FeatherSharp.Test.Resources.TestClassWithDependencies");

            featherImpl.ProcessType(type);

            CollectionAssert.AreEqual(
                Tuple.Create("FeatherSharp.Test.Resources.TestClassWithDependencies",
                             NpcInjectionTypeInfo.OkWithDependencies).Singleton(),
                callback.TypeInfos);

            CollectionAssert.AreEquivalent(
                Tuple.Create("C", NpcInjectionPropertyInfo.Ok).Singleton(),
                callback.PropertyInfos);

            CollectionAssert.AreEqual(
                new[]
            {
                Tuple.Create("D", "A,C"),
                Tuple.Create("E", "D,B"),
            },
                callback.PropertyDependencies);
        }
        public void TestBasicNpcInjection()
        {
            var callback    = new NpcFeatherCallback();
            var featherImpl = new NpcInjectionRunner(this.assembly.MainModule, callback);
            var type        = this.assembly.MainModule.GetType("FeatherSharp.Test.Resources.TestClass1");

            featherImpl.ProcessType(type);

            CollectionAssert.AreEqual(
                Tuple.Create("FeatherSharp.Test.Resources.TestClass1",
                             NpcInjectionTypeInfo.Ok).Singleton(),
                callback.TypeInfos);

            CollectionAssert.AreEquivalent(
                new[]
            {
                Tuple.Create("TestProperty_Int", NpcInjectionPropertyInfo.Ok),
                Tuple.Create("TestProperty_Object", NpcInjectionPropertyInfo.Ok),
                Tuple.Create("TestProperty_Struct", NpcInjectionPropertyInfo.Ok),
                Tuple.Create("TestProperty_String", NpcInjectionPropertyInfo.Ok),
                Tuple.Create("TestProperty_Complex", NpcInjectionPropertyInfo.NoEqualityCheckInjected),
                Tuple.Create("TestProperty_WithBodies", NpcInjectionPropertyInfo.Ok),
                Tuple.Create("TestProperty_WithRaise", NpcInjectionPropertyInfo.AlreadyCallsRaiseMethod),
            },
                callback.PropertyInfos);
        }
        ///////////////////////////////////////////////////////////////////////

        void FeatherAndWriteAssembly()
        {
            var callback = new NpcFeatherCallback();
            var feather  = new NpcInjectionFeather(callback);

            feather.Execute(this.assembly.MainModule, OutputFileName);
            this.assembly.Write(ModifiedOutputFileName, new WriterParameters());
        }
        public void TestInaccessibleRaiseMethod()
        {
            var callback    = new NpcFeatherCallback();
            var featherImpl = new NpcInjectionRunner(this.assembly.MainModule, callback);
            var type        = this.assembly.MainModule.GetType("FeatherSharp.Test.Resources.TestClassWithInaccessibleRaiseMethod");

            featherImpl.ProcessType(type);

            CollectionAssert.AreEqual(
                Tuple.Create("FeatherSharp.Test.Resources.TestClassWithInaccessibleRaiseMethod",
                             NpcInjectionTypeInfo.InaccessibleRaiseMethod).Singleton(),
                callback.TypeInfos);
        }
        public void TestIgnoreProperty()
        {
            var callback    = new NpcFeatherCallback();
            var featherImpl = new NpcInjectionRunner(this.assembly.MainModule, callback);
            var type        = this.assembly.MainModule.GetType("FeatherSharp.Test.Resources.TestClassWithIgnoredProperty");

            featherImpl.ProcessType(type);

            CollectionAssert.AreEqual(
                new[]
            {
                Tuple.Create("MyProperty", NpcInjectionPropertyInfo.Ok),
                Tuple.Create("MyIgnoredProperty", NpcInjectionPropertyInfo.Ignored),
            },
                callback.PropertyInfos);
        }
        public void TestTypeHierarchy()
        {
            var callback    = new NpcFeatherCallback();
            var featherImpl = new NpcInjectionRunner(this.assembly.MainModule, callback);
            var type        = this.assembly.MainModule.GetType("FeatherSharp.Test.Resources.TestClassWithBase");

            featherImpl.ProcessType(type);

            CollectionAssert.AreEqual(
                Tuple.Create("FeatherSharp.Test.Resources.TestClassWithBase",
                             NpcInjectionTypeInfo.Ok).Singleton(),
                callback.TypeInfos);

            CollectionAssert.AreEqual(
                Tuple.Create("MyProperty", NpcInjectionPropertyInfo.Ok).Singleton(),
                callback.PropertyInfos);
        }
        public void TestTypeFiltering()
        {
            var callback = new NpcFeatherCallback();
            var feather  = new NpcInjectionFeather(callback);

            feather.Execute(this.assembly.MainModule, OutputFileName);

            Action <string> assertContains = typeName =>
            {
                Assert.IsTrue(callback.TypeInfos.Any(typeInfo =>
                                                     typeInfo.Item1 == "FeatherSharp.Test.Resources." + typeName),
                              "Type " + typeName + " was not processed");
            };

            Action <string> assertNotContains = typeName =>
            {
                Assert.IsFalse(callback.TypeInfos.Any(typeInfo =>
                                                      typeInfo.Item1 == "FeatherSharp.Test.Resources." + typeName),
                               "Type " + typeName + " was processed by mistake");
            };

            assertContains("TestClass1");
            assertContains("TestClassWithBase");
            assertContains("TestClassBase");
            assertContains("TestClassWithouthInpc");
            assertContains("TestClassWithouthRaiseMethod");
            assertContains("TestClassWithOverride");
            assertContains("TestClassWithInaccessibleRaiseMethod");
            assertContains("TestClassWithInaccessibleRaiseMethodBase");
            assertContains("TestClassWithDependenciesBase");
            assertContains("TestClassWithDependencies");
            assertContains("TestClassWithDependencies");
            assertContains("TestClassContainer");
            assertContains("TestClassContainer/Nested");

            assertNotContains("TestClassWithOverrideBase");
        }