コード例 #1
0
        public void MultiMethodsTest3()
        {
            int callCount = 0;
            TypeDefinition <IMultiMethods1> typeDefinition =
                new TypeDefinition <IMultiMethods1>(
                    ActionMethod.Create("Foo", () => callCount++));
            IMultiMethods1 instance = typeDefinition.Create();

            instance.Foo();
            instance.Foo(5);
            instance.Foo("5");
            Assert.AreEqual(3, callCount);
        }
コード例 #2
0
        public void MultiMethodsTest5()
        {
            int callCount = 0;
            TypeDefinition <IMultiMethods1> typeDefinition =
                TypeDefinition <IMultiMethods1> .Create(ActionMethod.Create("Foo", (int a) => { }),
                                                        ActionMethod.Create("Foo", () => callCount++).CreateFallback());

            IMultiMethods1 instance = typeDefinition.CreateNew();

            instance.Foo();
            instance.Foo(5);
            instance.Foo("5");
            instance.Foo(out string _);
            Assert.AreEqual(3, callCount);
        }
コード例 #3
0
        public void MultiMethodsTestInvalid2()
        {
            TypeDefinition <IMultiMethods1> typeDefinition =
                new TypeDefinition <IMultiMethods1>(
                    ActionMethod.Create("Foo", (short value) => { }));
            IMultiMethods1 instance = typeDefinition.Create();

            instance.Foo(5);
        }
コード例 #4
0
        public void MultiMethodsTest2()
        {
            TypeDefinition <IMultiMethods1> typeDefinition =
                new TypeDefinition <IMultiMethods1>(
                    ActionMethod.Create("Foo", (int a) => { }));
            IMultiMethods1 instance = typeDefinition.Create();

            instance.Foo(5);
        }
コード例 #5
0
        public void MultiMethodsTestInvalid1()
        {
            TypeDefinition <IMultiMethods1> typeDefinition =
                TypeDefinition <IMultiMethods1> .Create(ActionMethod.Create("Foo", (string value) => { }));

            IMultiMethods1 instance = typeDefinition.CreateNew();

            instance.Foo(5);
        }
コード例 #6
0
        public void MultiMethodsTest1()
        {
            MultiImplementationInt          implentation   = new MultiImplementationInt();
            TypeDefinition <IMultiMethods1> typeDefinition =
                new TypeDefinition <IMultiMethods1>(implentation);
            IMultiMethods1 instance = typeDefinition.Create();

            instance.Foo(5);
            CollectionAssert.AreEquivalent(new[] { 5 }, implentation.CallList);
        }