Esempio n. 1
0
        public void GenericSimpleTest2()
        {
            BeethovenFactory beethovenFactory = new BeethovenFactory();
            IGenericMethods  instance         = beethovenFactory.Generate <IGenericMethods>(
                FuncMethod.Create("Simple", () => "abcd"),
                FuncMethod.Create("Simple", () => 5),
                FuncMethod.Create("Simple", () => (short)0));

            Assert.AreEqual(5, instance.Simple <int>());
            Assert.AreEqual(0, instance.Simple <short>());
            Assert.AreEqual("abcd", instance.Simple <string>());
        }
Esempio n. 2
0
        public void GenericSimpleTest4()
        {
            GenericMethods2  genericMethods2  = new GenericMethods2();
            BeethovenFactory beethovenFactory = new BeethovenFactory();
            IGenericMethods  instance         = beethovenFactory.Generate <IGenericMethods>(
                FuncMethod.Create("Simple", genericMethods2.SimpleString),
                FuncMethod.Create("Simple", genericMethods2.SimpleInt),
                genericMethods2);

            Assert.AreEqual(5, instance.Simple <int>());
            Assert.AreEqual("abcd", instance.Simple <string>());
        }
Esempio n. 3
0
        public void TestMethodFallbackMethod1()
        {
            int          callCount = 0;
            ITestMethods test      = TypeDefinition <ITestMethods> .Create(
                ActionMethod.Create("Simple", () => callCount++).CreateFallback(),
                FuncMethod.Create("ReturnValue", () => 5)
                )
                                     .CreateNew();

            Assert.AreEqual(5, test.ReturnValue());
            Assert.AreEqual(0, callCount);
            test.Simple();
            Assert.AreEqual(1, callCount);
        }