使用Ninject,我有以下,并希望利用FluentAssertions测试:如何测试我的工厂是否正确绑定?
[Test]
public void InterfacesEndingWithFactoryShouldBeBoundAsFactories() {
// Given
IKernel kernel = new StandardKernel();
kernel.Bind(services => services
.From(AppDomain.CurrentDomain
.GetAssemblies()
.Where(a => !a.FullName.Contains("Tests")))
.SelectAllInterfaces()
.EndingWith("Factory")
.BindToFactory()
);
// When
var factory = kernel.Get<ICustomerManagementPresenterFactory>();
// Then
factory.Should().NotBeNull();
}
有没有什么好的方法来测试是否工厂实际上是正确绑定?
对于任何SO社区成员,我已接受@KevinKuszyk答案,因为他提供了一种方法来执行我所要求的操作。此外,还应该考虑BatteryBackupUnit的答案,因为它也非常有启发性。两个答案都很有意义。 – 2014-12-05 14:15:34