Castle Windsor'un Akıcı Arayüzünü öğrenmeye çalışırken aşağıdaki basit testi yazdım:
using NUnit.Framework;
using Castle.Windsor;
using System.Collections;
using Castle.MicroKernel.Registration;
namespace WindsorSample {
public class MyComponent : IMyComponent {
public MyComponent(int start_at) {
this.Value = start_at;
}
public int Value { get; private set; }
}
public interface IMyComponent {
int Value { get; }
}
[TestFixture]
public class ConcreteImplFixture {
[Test]
public void ResolvingConcreteImplShouldInitialiseValue() {
IWindsorContainer container = new WindsorContainer();
container.Register(Component.For<IMyComponent>().ImplementedBy<MyComponent>().Parameters(Parameter.ForKey("start_at").Eq("1")));
IMyComponent resolvedComp = container.Resolve<IMyComponent>();
Assert.AreEqual(resolvedComp.Value, 1);
}
}
}
Testi TestDriven.NET aracılığıyla yürüttüğümde aşağıdaki hatayı alıyorum:
System.TypeLoadException : Could not load type 'Castle.MicroKernel.Registration.IRegistration' from assembly 'Castle.MicroKernel, Version=1.0.3.0, Culture=neutral, PublicKeyToken=407dd0808d44fbdc'.
at WindsorSample.ConcreteImplFixture.ResolvingConcreteImplShouldInitialiseValue()
Testi NUnit GUI aracılığıyla yürüttüğümde şunu elde ediyorum:
WindsorSample.ConcreteImplFixture.ResolvingConcreteImplShouldInitialiseValue:
System.IO.FileNotFoundException : Could not load file or assembly 'Castle.Windsor, Version=1.0.3.0, Culture=neutral, PublicKeyToken=407dd0808d44fbdc' or one of its dependencies. The system cannot find the file specified.
Reflector'da referans verdiğim Meclisi açarsam, bilgilerinin şöyle olduğunu görebilirim:
Castle.MicroKernel, Version=1.0.3.0, Culture=neutral, PublicKeyToken=407dd0808d44fbdc
ve kesinlikle Castle.MicroKernel.Registration.IRegistration içerdiğini
Ne oluyor olabilir?
Nant ile hiç çalışmadığım halde , ikililerin Castle'ın en son sürümünden alındığını belirtmeliyim, bu yüzden kaynaktan yeniden derleme zahmetine girmedim ve sadece bin dizinindeki dosyaları aldım. Ayrıca projemin sorunsuz derlendiğini de belirtmeliyim.
