コード例 #1
0
        public void CorrectBinaryOverload()
        {
            dynamic d = new HasVarargs();

            Assert.Equal(7, d.Binary(3, 4));
            Assert.Equal(8, d.Binary((byte)2, (byte)6));
        }
コード例 #2
0
        public void FailBindOnlyVarargsAvailable()
        {
            dynamic d            = new HasVarargs();
            string  errorMessage = Assert.Throws <RuntimeBinderException>(() => d.OnlyVarargs()).Message;

            // No overload for method 'OnlyVarargs' takes '0' arguments
            // Localized forms should contain the name and count.
            Assert.Contains("OnlyVarargs", errorMessage);
            Assert.Contains("0", errorMessage);
            errorMessage = Assert.Throws <RuntimeBinderException>(() => d.OnlyVarargs(1)).Message;
            // "The best overloaded method match for 'Microsoft.CSharp.RuntimeBinder.Tests.VarArgsTests.HasVarargs.OnlyVarargs(__arglist)' has some invalid arguments"
            // Localized form should contain the name,
            Assert.Contains("Microsoft.CSharp.RuntimeBinder.Tests.VarArgsTests.HasVarargs.OnlyVarargs(__arglist)", errorMessage);
        }
コード例 #3
0
        public void CorrectUnaryOverloadNeedingImplicitConversion()
        {
            dynamic d = new HasVarargs();

            Assert.Equal(9392, d.Unary1(9392));
        }
コード例 #4
0
        public void CorrectUnaryOverload()
        {
            dynamic d = new HasVarargs();

            Assert.Equal(32, d.Unary0(32));
        }
コード例 #5
0
        public void CorrectNullaryOverload()
        {
            dynamic d = new HasVarargs();

            Assert.Equal(1, d.Nullary());
        }