private void DoTestNestedGenerics <TKey, TValue>(TKey[] arg, Dictionary <TKey, TValue> expectedRetval) { var handler = CreateClass("MyService", "NestedGenerics")(new[] { typeof(TKey), typeof(TValue) }); var argCodec = codecContainer.GetManualCodecFor <TKey[]>(); var resultCodec = codecContainer.GetManualCodecFor <Dictionary <TKey, TValue> >(); var data = new byte[argCodec.CalculateSize(arg)]; fixed(byte *pData = data) { var p = pData; argCodec.Encode(ref p, arg); } var expectedData = new byte[resultCodec.CalculateSize(expectedRetval)]; fixed(byte *pData = expectedData) { var p = pData; resultCodec.Encode(ref p, expectedRetval); } service.NestedGenerics <TKey, TValue>(arg).ReturnsForAnyArgs(expectedRetval); var result = handler.Handle(service, data, 0).Result; var serviceCall = service.ReceivedCalls().Last(); Assert.That(serviceCall.GetMethodInfo(), Is.EqualTo(typeof(IGlobalService).GetMethod("NestedGenerics").MakeGenericMethod(new[] { typeof(TKey), typeof(TValue) }))); Assert.That(serviceCall.GetArguments()[0], Is.EquivalentTo(arg)); Assert.That(result, Is.EquivalentTo(expectedData)); }