public void SupportsProperlyEncodedSingleConstants() { var source = typeof(ILMethodsWithDefaultParameters).GetMethod(nameof(SinglesEncodedProperly)); var shim = ShimGenerator.WithDefaultParametersPassed <Func <bool> >(source); Assert.True(shim()); }
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)); }
public void SupportsValidCSharpDefaultParameters() { var source = typeof(ShimGeneratorTests).GetMethod(nameof(MethodWithAllPossibleCSharpDefaultParameters)); var shim = ShimGenerator.WithDefaultParametersPassed <Func <bool> >(source); Assert.True(shim()); }
//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)); }
public void SupportsDateTimeConstantAttribute() { var source = typeof(ILMethodsWithDefaultParameters).GetMethod(nameof(DateTimeEncodedAttribute)); var shim = ShimGenerator.WithDefaultParametersPassed <Func <bool> >(source); Assert.True(shim()); }
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))); }
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))))); }
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))))); }
public void DoesNotSupportInParameters() { var source = typeof(ShimGeneratorTests).GetMethod(nameof(MethodWithDefaultInParameters)); Assert.NotNull(Record.Exception(() => ShimGenerator.WithDefaultParametersPassed <Func <int> >(source))); }
public void DoesNotSupportReturnTypeMismatch() { var source = typeof(ShimGeneratorTests).GetMethod(nameof(MethodWithAllPossibleCSharpDefaultParameters)); Assert.NotNull(Record.Exception(() => ShimGenerator.WithDefaultParametersPassed <Func <int> >(source))); }