[TestClass]
public class LinFuProxyTests
{
[TestMethod]
public void CreateProxyTest()
{
var target = new SampleClass();
var factory = new ProxyFactory();
var interceptor = new SampleInterceptor(target);
var proxy = factory.CreateProxy<SampleClass>(interceptor);
}
}
public class SampleClass : ICloneable
{
object ICloneable.Clone()
{
return new SampleClass();
}
}
public class SampleInterceptor : IInvokeWrapper
{
public SampleInterceptor(object target)
{
this.Target = target;
}
public object Target { get; private set; }
object IInvokeWrapper.DoInvoke(IInvocationInfo info)
{
return null;
}
void IBeforeInvoke.BeforeInvoke(IInvocationInfo info)
{
}
void IAfterInvoke.AfterInvoke(IInvocationInfo info, object returnValue)
{
}
}
Result of the unit test is:
Test method LinFuProxyTests.CreateProxyTest threw exception:
System.ArgumentNullException: Value cannot be null.
Parameter name: type
at System.Activator.CreateInstance(Type type, Boolean nonPublic)
at System.Activator.CreateInstance(Type type)
at LinFu.Proxy.Interfaces.ProxyFactoryExtensions.CreateProxy(IProxyFactory factory, Type instanceType, IInterceptor interceptor, Type[] baseInterfaces)
at LinFu.Proxy.Interfaces.ProxyFactoryExtensions.CreateProxy(IProxyFactory factory, Type instanceType, IInvokeWrapper wrapper, Type[] baseInterfaces)
at LinFu.Proxy.Interfaces.ProxyFactoryExtensions.CreateProxy(IProxyFactory factory, IInvokeWrapper wrapper, Type[] baseInterfaces)
at LinFuProxyTests.CreateProxyTest() in LinFuProxyTests.cs: line 28
The title says more or less all. A little sample:
Result of the unit test is:
Test method LinFuProxyTests.CreateProxyTest threw exception: System.ArgumentNullException: Value cannot be null. Parameter name: type at System.Activator.CreateInstance(Type type, Boolean nonPublic) at System.Activator.CreateInstance(Type type) at LinFu.Proxy.Interfaces.ProxyFactoryExtensions.CreateProxy(IProxyFactory factory, Type instanceType, IInterceptor interceptor, Type[] baseInterfaces) at LinFu.Proxy.Interfaces.ProxyFactoryExtensions.CreateProxy(IProxyFactory factory, Type instanceType, IInvokeWrapper wrapper, Type[] baseInterfaces) at LinFu.Proxy.Interfaces.ProxyFactoryExtensions.CreateProxy(IProxyFactory factory, IInvokeWrapper wrapper, Type[] baseInterfaces) at LinFuProxyTests.CreateProxyTest() in LinFuProxyTests.cs: line 28