コード例 #1
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>());
        }
コード例 #2
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>());
        }
コード例 #3
0
        public void GenericSimpleTest1()
        {
            GenericMethods   genericMethods   = new GenericMethods();
            BeethovenFactory beethovenFactory = new BeethovenFactory();
            IGenericMethods  instance         = beethovenFactory.Generate <IGenericMethods>(genericMethods);
            List <string>    calledMethods    = new List <string>();

            genericMethods.MethodCalled += s => calledMethods.Add(s);
            Assert.AreEqual(5, instance.Simple <int>());
            Assert.AreEqual(0, instance.Simple <short>());
            Assert.AreEqual("abcd", instance.Simple <string>());
            CollectionAssert.AreEquivalent(new[] { "Simple", "Simple", "Simple" }, calledMethods);
        }
コード例 #4
0
        public void LinkedMethodsTest12()
        {
            BeethovenFactory beethovenFactory = new BeethovenFactory();
            IGenericMethods  instance         = beethovenFactory.Generate <IGenericMethods>(
                LinkedMethodsReturnValue.Create <IGenericMethods>(nameof(IGenericMethods.Simple))
                .Func(() => true)
                .FlowControl(() => false)
                .Func(() => false));

            Assert.AreEqual(true, instance.Simple <bool>());
        }