Napisałem następujący prosty test, próbując nauczyć się płynnego interfejsu Castle Windsor:
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);
}
}
}
Kiedy wykonuję test za pomocą TestDriven.NET, pojawia się następujący błąd:
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()
Kiedy wykonuję test przez GUI NUnit, otrzymuję:
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.
Jeśli otworzę zestaw, do którego się odwołuję w Reflector, zobaczę, że jego informacje to:
Castle.MicroKernel, Version=1.0.3.0, Culture=neutral, PublicKeyToken=407dd0808d44fbdc
i że na pewno zawiera Castle.MicroKernel.Registration.IRegistration
Co się mogło dziać?
Powinienem wspomnieć, że pliki binarne są pobierane z najnowszej wersji Castle'a, chociaż nigdy nie pracowałem z nantem, więc nie zawracałem sobie głowy ponowną kompilacją ze źródła i po prostu wziąłem pliki z katalogu bin. Powinienem również zaznaczyć, że mój projekt kompiluje się bez problemu.
