コード例 #1
0
        public void SupportsProperlyEncodedSingleConstants()
        {
            var source = typeof(ILMethodsWithDefaultParameters).GetMethod(nameof(SinglesEncodedProperly));
            var shim   = ShimGenerator.WithDefaultParametersPassed <Func <bool> >(source);

            Assert.True(shim());
        }
コード例 #2
0
        public void SupportsShimsForNoDefaultParameters()
        {
            var source = typeof(ShimGeneratorTests).GetMethod(nameof(MethodWithoutDefaultParameters));
            var shim   = ShimGenerator.WithDefaultParametersPassed <Func <double, string, int, object, bool> >(source);

            Assert.True(shim(Float64Constant, LiteralString, Int32Constant, null));
        }
コード例 #3
0
        public void SupportsValidCSharpDefaultParameters()
        {
            var source = typeof(ShimGeneratorTests).GetMethod(nameof(MethodWithAllPossibleCSharpDefaultParameters));
            var shim   = ShimGenerator.WithDefaultParametersPassed <Func <bool> >(source);

            Assert.True(shim());
        }
コード例 #4
0
        //Note that this support is not just a checkbox. There is a proposal on csharplang for this, and it has recently been looked at by the LDT
        public void SupportsNonTrailingDefaultParameters()
        {
            var source = typeof(ILMethodsWithDefaultParameters).GetMethod(nameof(MethodWithNonTrailingDefaultParameters));
            var shim   = ShimGenerator.WithDefaultParametersPassed <Func <float, sbyte, bool> >(source);

            Assert.True(shim(32f, 8));
        }
コード例 #5
0
        public void SupportsDateTimeConstantAttribute()
        {
            var source = typeof(ILMethodsWithDefaultParameters).GetMethod(nameof(DateTimeEncodedAttribute));
            var shim   = ShimGenerator.WithDefaultParametersPassed <Func <bool> >(source);

            Assert.True(shim());
        }
コード例 #6
0
        public void TargetParameterMustExactlyMatchRequiredSourceParameters()
        {
            var source = typeof(ShimGeneratorTests).GetMethod(nameof(MethodWithDefaultAndRequiredParameters));

            Assert.NotNull(Record.Exception(() => ShimGenerator.WithDefaultParametersPassed <Func <string, double, bool> >(source)));
            Assert.NotNull(Record.Exception(() => ShimGenerator.WithDefaultParametersPassed <Func <long, string, bool> >(source)));
            Assert.NotNull(Record.Exception(() => ShimGenerator.WithDefaultParametersPassed <Func <decimal, double, bool> >(source)));
            Assert.NotNull(Record.Exception(() => ShimGenerator.WithDefaultParametersPassed <Func <double, string, int, object, bool> >(source)));
        }
コード例 #7
0
        public void DoesNotSupportBadlyEncodedInt64Constants()
        {
            var type = typeof(ILMethodsWithDefaultParameters);

            Assert.NotNull(Record.Exception(() => ShimGenerator.WithDefaultParametersPassed <Func <bool> >(type.GetMethod(nameof(Int64EncodedWithBoolean)))));
            Assert.NotNull(Record.Exception(() => ShimGenerator.WithDefaultParametersPassed <Func <bool> >(type.GetMethod(nameof(Int64EncodedWithChar)))));
            Assert.NotNull(Record.Exception(() => ShimGenerator.WithDefaultParametersPassed <Func <bool> >(type.GetMethod(nameof(Int64EncodedWithTooBigUInt64)))));
            Assert.NotNull(Record.Exception(() => ShimGenerator.WithDefaultParametersPassed <Func <bool> >(type.GetMethod(nameof(Int64EncodedWithSingle)))));
            Assert.NotNull(Record.Exception(() => ShimGenerator.WithDefaultParametersPassed <Func <bool> >(type.GetMethod(nameof(Int64EncodedWithDouble)))));
        }
コード例 #8
0
        public void DoesNotSupportBadlyEncodedNativeIntegerConstants()
        {
            var type = typeof(ILMethodsWithDefaultParameters);

            Assert.NotNull(Record.Exception(() => ShimGenerator.WithDefaultParametersPassed <Func <bool> >(type.GetMethod(nameof(NativeIntEncodedWithBoolean)))));
            Assert.NotNull(Record.Exception(() => ShimGenerator.WithDefaultParametersPassed <Func <bool> >(type.GetMethod(nameof(NativeIntEncodedWithChar)))));
            Assert.NotNull(Record.Exception(() => ShimGenerator.WithDefaultParametersPassed <Func <bool> >(type.GetMethod(nameof(NativeIntEncodedWithTooBigUInt32)))));
            Assert.NotNull(Record.Exception(() => ShimGenerator.WithDefaultParametersPassed <Func <bool> >(type.GetMethod(nameof(NativeIntEncodedWithTooSmallInt64)))));
            Assert.NotNull(Record.Exception(() => ShimGenerator.WithDefaultParametersPassed <Func <bool> >(type.GetMethod(nameof(NativeIntEncodedWithTooBigInt64)))));
            Assert.NotNull(Record.Exception(() => ShimGenerator.WithDefaultParametersPassed <Func <bool> >(type.GetMethod(nameof(NativeIntEncodedWithTooBigUInt64)))));

            Assert.NotNull(Record.Exception(() => ShimGenerator.WithDefaultParametersPassed <Func <bool> >(type.GetMethod(nameof(NativeUIntEncodedWithBoolean)))));
            Assert.NotNull(Record.Exception(() => ShimGenerator.WithDefaultParametersPassed <Func <bool> >(type.GetMethod(nameof(NativeUIntEncodedWithChar)))));
            Assert.NotNull(Record.Exception(() => ShimGenerator.WithDefaultParametersPassed <Func <bool> >(type.GetMethod(nameof(NativeUIntEncodedWithTooSmallInt8)))));
            Assert.NotNull(Record.Exception(() => ShimGenerator.WithDefaultParametersPassed <Func <bool> >(type.GetMethod(nameof(NativeUIntEncodedWithTooSmallInt16)))));
            Assert.NotNull(Record.Exception(() => ShimGenerator.WithDefaultParametersPassed <Func <bool> >(type.GetMethod(nameof(NativeUIntEncodedWithTooSmallInt32)))));
            Assert.NotNull(Record.Exception(() => ShimGenerator.WithDefaultParametersPassed <Func <bool> >(type.GetMethod(nameof(NativeUIntEncodedWithTooSmallInt64)))));
            Assert.NotNull(Record.Exception(() => ShimGenerator.WithDefaultParametersPassed <Func <bool> >(type.GetMethod(nameof(NativeUIntEncodedWithTooBigInt64)))));
            Assert.NotNull(Record.Exception(() => ShimGenerator.WithDefaultParametersPassed <Func <bool> >(type.GetMethod(nameof(NativeUIntEncodedWithTooBigUInt64)))));
        }
コード例 #9
0
        public void DoesNotSupportInParameters()
        {
            var source = typeof(ShimGeneratorTests).GetMethod(nameof(MethodWithDefaultInParameters));

            Assert.NotNull(Record.Exception(() => ShimGenerator.WithDefaultParametersPassed <Func <int> >(source)));
        }
コード例 #10
0
        public void DoesNotSupportReturnTypeMismatch()
        {
            var source = typeof(ShimGeneratorTests).GetMethod(nameof(MethodWithAllPossibleCSharpDefaultParameters));

            Assert.NotNull(Record.Exception(() => ShimGenerator.WithDefaultParametersPassed <Func <int> >(source)));
        }