private void returns_intercepted_parameters_as_string_when_GenericReturnInterceptedRefParametersAsString_is_called() { Execute(() => { var instance = new InterceptGenericMethodsWithConstraintsClass <InheritsFromSimpleClass, SimpleClass>(); var interceptedP1 = new InheritsFromSimpleClass(2); var interceptedP2 = new SimpleClass(2); var interceptedP3 = new SimpleStruct(2); var interceptedP4 = new SimpleClass(2); var expected = Helper.AsString(interceptedP1, interceptedP2, interceptedP3, interceptedP4); var p1 = new InheritsFromSimpleClass(1); var p2 = new SimpleClass(1); var p3 = new SimpleStruct(1); var p4 = new SimpleClass(1); var ref1 = p1; var ref2 = p2; var ref3 = p3; var ref4 = p4; var result = instance.GenericReturnInterceptedRefParametersAsString <SimpleStruct, SimpleClass>(ref ref1, ref ref2, ref ref3, ref ref4); Assert.Equal(expected, result); Assert.NotEqual(p1, ref1); Assert.NotSame(p2, ref2); Assert.NotEqual(p3, ref3); Assert.NotSame(p4, ref4); }); }
public InterceptPropertiesClass() { object TValue = new InheritsFromSimpleClass(1); OriginalValueType = 1; OriginalRefType = "a"; OriginalExternalValueType = new SimpleStruct(1); OriginalExternalRefType = new SimpleClass(1); OriginalGenericType = (T)TValue; OriginalValueTypeArray = new[] { 1 }; OriginalRefTypeArray = new[] { "a" }; OriginalExternalValueTypeArray = new[] { new SimpleStruct(1) }; OriginalExternalRefTypeArray = new[] { new SimpleClass(1) }; OriginalGenericTypeArray = new[] { (T)TValue }; OriginalValueTypeList = new List <int> { 1 }; OriginalRefTypeList = new List <string> { "a" }; OriginalExternalValueTypeList = new List <SimpleStruct> { new SimpleStruct(1) }; OriginalExternalRefTypeList = new List <SimpleClass> { new SimpleClass(1) }; OriginalGenericTypeList = new List <T> { (T)TValue }; InterceptedValueType = 1; InterceptedRefType = "a"; InterceptedExternalValueType = new SimpleStruct(1); InterceptedExternalRefType = new SimpleClass(1); InterceptedGenericType = (T)TValue; InterceptedValueTypeArray = new[] { 1 }; InterceptedRefTypeArray = new[] { "a" }; InterceptedExternalValueTypeArray = new[] { new SimpleStruct(1) }; InterceptedExternalRefTypeArray = new[] { new SimpleClass(1) }; InterceptedGenericTypeArray = new[] { (T)TValue }; InterceptedValueTypeList = new List <int> { 1 }; InterceptedRefTypeList = new List <string> { "a" }; InterceptedExternalValueTypeList = new List <SimpleStruct> { new SimpleStruct(1) }; InterceptedExternalRefTypeList = new List <SimpleClass> { new SimpleClass(1) }; InterceptedGenericTypeList = new List <T> { (T)TValue }; }
private void returns_original_parameters_as_string_when_ReturnOriginalParametersAsString_is_called() { Execute(() => { var instance = new InterceptGenericMethodsWithConstraintsClass <InheritsFromSimpleClass, SimpleClass>(); var p1 = new InheritsFromSimpleClass(1); var p2 = new SimpleClass(1); var expected = Helper.AsString(p1, p2); var result = instance.ReturnOriginalParametersAsString(p1, p2); Assert.Equal(expected, result); }); }
private void returns_original_parameters_as_string_when_GenericWithRepeatedGenericParameterReturnOriginalParametersAsString_is_called() { Execute(() => { var instance = new InterceptGenericMethodsWithConstraintsClass <InheritsFromSimpleClass, SimpleClass>(); var p1 = new InheritsFromSimpleClass(1); var p2 = new[] { "a" }; var p3 = new[] { 1 }; var expected = Helper.AsString(p1, p2, p3); var result = instance.GenericWithRepeatedGenericParameterReturnOriginalParametersAsString <int[], IEnumerable>(p1, p2, p3); Assert.Equal(expected, result); }); }
private void returns_intercepted_parameters_as_string_when_GenericWithRepeatedGenericParameterReturnInterceptedOutParameters_is_called() { Execute(() => { var instance = new InterceptGenericMethodsWithConstraintsClass <InheritsFromSimpleClass, SimpleClass>(); var interceptedP1 = new InheritsFromSimpleClass(2); var interceptedP2 = new[] { "ab" } as IEnumerable; var interceptedP3 = new[] { 2 }; var interceptedP4 = new[] { new InheritsFromSimpleClass(1), new InheritsFromSimpleClass(2) }; var interceptedP5 = new[] { new[] { "ab" } }; var interceptedP6 = new[] { new[] { 2 } }; var interceptedP7 = new List <InheritsFromSimpleClass> { new InheritsFromSimpleClass(1), new InheritsFromSimpleClass(2) }; var interceptedP8 = new List <IEnumerable> { new[] { "ab" } }; var interceptedP9 = new List <int[]> { new[] { 2 } }; InheritsFromSimpleClass out1; IEnumerable out2; int[] out3; InheritsFromSimpleClass[] out4; IEnumerable[] out5; int[][] out6; List <InheritsFromSimpleClass> out7; List <IEnumerable> out8; List <int[]> out9; instance.GenericWithRepeatedGenericParameterReturnInterceptedOutParameters <int[], IEnumerable>(out out1, out out2, out out3, out out4, out out5, out out6, out out7, out out8, out out9); Assert.Equal(interceptedP1.Value, out1.Value); Assert.Equal(interceptedP2.Cast <string>().First(), out2.Cast <string>().First()); Assert.Equal(interceptedP3[0], out3[0]); Assert.Equal(interceptedP4[0].Value, out4[0].Value); Assert.Equal(interceptedP4[1].Value, out4[1].Value); Assert.Equal(interceptedP5[0].Cast <string>().First(), out5[0].Cast <string>().First()); Assert.Equal(interceptedP6[0][0], out6[0][0]); Assert.Equal(interceptedP7[0].Value, out7[0].Value); Assert.Equal(interceptedP7[1].Value, out7[1].Value); Assert.Equal(interceptedP8[0].Cast <string>().First(), out8[0].Cast <string>().First()); Assert.Equal(interceptedP9[0][0], out9[0][0]); }); }
private void returns_intercepted_parameters_as_string_when_GenericReturnInterceptedParametersAsString_is_called() { Execute(() => { var instance = new InterceptGenericMethodsWithConstraintsClass <InheritsFromSimpleClass, SimpleClass>(); var interceptedP1 = new InheritsFromSimpleClass(2); var interceptedP2 = new SimpleClass(2); var interceptedP3 = new SimpleStruct(2); var interceptedP4 = new SimpleClass(2); var expected = Helper.AsString(interceptedP1, interceptedP2, interceptedP3, interceptedP4); var originalP1 = new InheritsFromSimpleClass(1); var originalP2 = new SimpleClass(1); var originalP3 = new SimpleStruct(1); var originalP4 = new SimpleClass(1); var result = instance.GenericReturnInterceptedParametersAsString <SimpleStruct, SimpleClass>(originalP1, originalP2, originalP3, originalP4); Assert.Equal(expected, result); }); }
private void returns_intercepted_parameters_as_string_when_GenericWithRepeatedGenericParameterReturnInterceptedRefParametersAsString_is_called() { Execute(() => { var instance = new InterceptGenericMethodsWithConstraintsClass <InheritsFromSimpleClass, SimpleClass>(); var interceptedP1 = new InheritsFromSimpleClass(2); var interceptedP2 = new[] { "ab" }; var interceptedP3 = new[] { 2 }; var expected = Helper.AsString(interceptedP1, interceptedP2, interceptedP3); var p1 = new InheritsFromSimpleClass(1); var p2 = new[] { "a" } as IEnumerable; var p3 = new[] { 1 }; var ref1 = p1; var ref2 = p2; var ref3 = p3; var result = instance.GenericWithRepeatedGenericParameterReturnInterceptedRefParametersAsString <int[], IEnumerable>(ref ref1, ref ref2, ref ref3); Assert.Equal(expected, result); Assert.NotEqual(p1, ref1); Assert.NotEqual(p2, ref2); Assert.NotSame(p3, ref3); }); }
private void returns_intercepted_parameters_as_string_when_ReturnInterceptedOutParameters_is_called() { Execute(() => { var instance = new InterceptGenericMethodsWithConstraintsClass <InheritsFromSimpleClass, SimpleClass>(); var interceptedP1 = new InheritsFromSimpleClass(2); var interceptedP2 = new SimpleClass(2); var interceptedP3 = new[] { new InheritsFromSimpleClass(1), new InheritsFromSimpleClass(2) }; var interceptedP4 = new[] { new SimpleClass(1), new SimpleClass(2) }; var interceptedP5 = new List <InheritsFromSimpleClass> { new InheritsFromSimpleClass(1), new InheritsFromSimpleClass(2) }; var interceptedP6 = new List <SimpleClass> { new SimpleClass(1), new SimpleClass(2) }; InheritsFromSimpleClass out1; SimpleClass out2; InheritsFromSimpleClass[] out3; SimpleClass[] out4; List <InheritsFromSimpleClass> out5; List <SimpleClass> out6; instance.ReturnInterceptedOutParameters(out out1, out out2, out out3, out out4, out out5, out out6); Assert.Equal(interceptedP1.Value, out1.Value); Assert.Equal(interceptedP2.Value, out2.Value); Assert.Equal(interceptedP3[0].Value, out3[0].Value); Assert.Equal(interceptedP3[1].Value, out3[1].Value); Assert.Equal(interceptedP4[0].Value, out4[0].Value); Assert.Equal(interceptedP4[1].Value, out4[1].Value); Assert.Equal(interceptedP5[0].Value, out5[0].Value); Assert.Equal(interceptedP5[1].Value, out5[1].Value); Assert.Equal(interceptedP6[0].Value, out6[0].Value); Assert.Equal(interceptedP6[1].Value, out6[1].Value); }); }
private void returns_intercepted_parameters_as_string_when_GenericReturnInterceptedOutParameters_is_called() { Execute(() => { var instance = new InterceptGenericMethodsWithConstraintsClass <InheritsFromSimpleClass, SimpleClass>(); var interceptedP1 = new InheritsFromSimpleClass(2); var interceptedP2 = new SimpleClass(2); var interceptedP3 = new SimpleStruct(2); var interceptedP4 = new SimpleClass(2); var interceptedP5 = new[] { new InheritsFromSimpleClass(1), new InheritsFromSimpleClass(2) }; var interceptedP6 = new[] { new SimpleClass(1), new SimpleClass(2) }; var interceptedP7 = new[] { new SimpleStruct(1), new SimpleStruct(2) }; var interceptedP8 = new[] { new SimpleClass(1), new SimpleClass(2) }; var interceptedP9 = new List <InheritsFromSimpleClass> { new InheritsFromSimpleClass(1), new InheritsFromSimpleClass(2) }; var interceptedP10 = new List <SimpleClass> { new SimpleClass(1), new SimpleClass(2) }; var interceptedP11 = new List <SimpleStruct> { new SimpleStruct(1), new SimpleStruct(2) }; var interceptedP12 = new List <SimpleClass> { new SimpleClass(1), new SimpleClass(2) }; InheritsFromSimpleClass out1; SimpleClass out2; SimpleStruct out3; SimpleClass out4; InheritsFromSimpleClass[] out5; SimpleClass[] out6; SimpleStruct[] out7; SimpleClass[] out8; List <InheritsFromSimpleClass> out9; List <SimpleClass> out10; List <SimpleStruct> out11; List <SimpleClass> out12; instance.GenericReturnInterceptedOutParameters <SimpleStruct, SimpleClass>(out out1, out out2, out out3, out out4, out out5, out out6, out out7, out out8, out out9, out out10, out out11, out out12); Assert.Equal(interceptedP1.Value, out1.Value); Assert.Equal(interceptedP2.Value, out2.Value); Assert.Equal(interceptedP3.Value, out3.Value); Assert.Equal(interceptedP4.Value, out4.Value); Assert.Equal(interceptedP5[0].Value, out5[0].Value); Assert.Equal(interceptedP5[1].Value, out5[1].Value); Assert.Equal(interceptedP6[0].Value, out6[0].Value); Assert.Equal(interceptedP6[1].Value, out6[1].Value); Assert.Equal(interceptedP7[0].Value, out7[0].Value); Assert.Equal(interceptedP7[1].Value, out7[1].Value); Assert.Equal(interceptedP8[0].Value, out8[0].Value); Assert.Equal(interceptedP8[1].Value, out8[1].Value); Assert.Equal(interceptedP9[0].Value, out9[0].Value); Assert.Equal(interceptedP9[1].Value, out9[1].Value); Assert.Equal(interceptedP10[0].Value, out10[0].Value); Assert.Equal(interceptedP10[1].Value, out10[1].Value); Assert.Equal(interceptedP11[0].Value, out11[0].Value); Assert.Equal(interceptedP11[1].Value, out11[1].Value); Assert.Equal(interceptedP12[0].Value, out12[0].Value); Assert.Equal(interceptedP12[1].Value, out12[1].Value); }); }