Hi Philip
It looks like it is a problem using NMock with Dynamic Proxy..
I replaced a mock object with a real object and the test passed.
so... using new XIA instead of NewMock<X<IA>>(); makes it work.
Using NMock causes a Bad IL exception.
class XIA : X<IA>
{
private IA result;
public XIA(IA result)
{
this.result = result;
}
public IA DoSomething()
{
return result;
}
}
public interface X<T>
{
T DoSomething();
}
public interface IA
{
}
my test now reads...
[TestFixture]
public class ProxyFactoryTests : MockingTestFixture
{
[Test]
public void CanProxyGenericTypes()
{
IA ia = NewMock<IA>();
X<IA> mockX = new XIA(ia);
PassThrough<X<IA>> passthrough = new
PassThrough<X<IA>>(mockX);
ProxyFactory factory = new ProxyFactory();
X<IA> proxy = factory.CreateProxy<X<IA>>(passthrough);
Assert.AreSame(ia, proxy.DoSomething());
}
protected override void SetUp()
{
}
}
Note: MockingTestFixture is just a baseclass for mocking tests that
creates a mockery, exposed NewMock as a helper method and does
validation on teardown. (From NMockExtensions)