public void NonGenericGetRegistrationsIncludesAllButOnlyExpectedRegistrations() { using (var iocContainer = new IocContainer()) { var namelessFoo = iocContainer.Register(typeof(IFoo), c => new Foo1()); var bobFoo = iocContainer.Register("Bob", typeof(IFoo), c => new Foo2()); var billFoo = iocContainer.Register("Bill", typeof(IFoo), c => new Foo2()); var janeBar = iocContainer.Register("Jane", typeof(IBar), c => new Bar1()); var result = iocContainer.GetRegistrations(typeof(IFoo)); Verify.That(result.ToList()).IsACollectionThat() .IsAnInstanceOfType(typeof(List<IRegistration>)) .Count().IsEqualTo(3) .AllItemsAreInstancesOfType(typeof(IRegistration)) .Contains(namelessFoo) .Contains(bobFoo) .Contains(billFoo) .DoesNotContain(janeBar); } }
public void GetRegistrationsReturnsAnEmptyListIfNoRegistrationsOfTheRequesetedType() { using (var iocContainer = new IocContainer()) { iocContainer.Register<IFoo>(c => new Foo1()); iocContainer.Register<IFoo>("Bob", c => new Foo2()); iocContainer.Register<IFoo>("Bill", c => new Foo2()); var result = iocContainer.GetRegistrations<IBar>(); Verify.That(result.ToList()).IsACollectionThat() .IsAnInstanceOfType(typeof(List<IRegistration>)) .Count().IsEqualTo(0); } }