Menu

#6 BadImageFormatException

open
nobody
5
2009-06-23
2009-06-23
No

using System;
using Castle.Core.Interceptor;
using Castle.DynamicProxy;
using NUnit.Framework;
using System.Collections.Generic;

namespace Pharmatechnik.Apotheke.XTplus.Framework.TestLibrary.Tests {
public interface IPersistenceQuery2<TResult> {}

public interface IBOBase2 {}

public interface ITest1 {
List<TBase> Find<TBase, T>(IPersistenceQuery2<T> query) where TBase : class where T : class, TBase, IBOBase2;
}

public interface IDummyFactory {}

public class Test2 {
private readonly IDummyFactory[] _factories;

public Test2(IDummyFactory[] factories) {
_factories = factories;
}
}

public class Interceptor : IInterceptor {
public void Intercept(IInvocation invocation) {
invocation.Proceed();
}
}

public interface ITest3 {
T New<T>(params Action<T>[] actions) where T : class;
}

public class Test3 : ITest3 {
private readonly Test4 _test4;

public Test3(Test4 test4) {
_test4 = test4;
}

public virtual T New<T>(params Action<T>[] actions) where T : class {
_test4.Execute();
return default(T);
}
}

public class Test4 {
public virtual void Execute() {}
}

[TestFixture]
public class DP2Troubles {
[Test]
public void BadImageFormatException_CreateInterfaceProxyWithoutTarget_Case1() {
var generator = new ProxyGenerator();
generator.CreateInterfaceProxyWithoutTarget<ITest1>();
}

[Test]
public void MissionMethodException_CreateClassProxy_Case2() {
var generator = new ProxyGenerator();
generator.CreateClassProxy(typeof (Test2), new IInterceptor[] {new Interceptor()}, new IDummyFactory[] {});
}

[Test]
public void BadImageFormatException_CreateClassProxy_Case3() {
var generator = new ProxyGenerator();
var test3 = (Test3) generator.CreateClassProxy(typeof (Test3), new IInterceptor[] {new Interceptor()}, new Test4());
test3.New<object>();
}
}
}

Discussion


Log in to post a comment.