public void AttemptingNonGenericNamelessGetRegistrationForANonexistingEntryThrows() { using (var iocContainer = new IocContainer()) { Verify.TheExpectedException(typeof(KeyNotFoundException)).IsThrownWhen( () => iocContainer.GetRegistration(typeof(IFoo)) ).AndHasAMessageThat().IsEqualTo("Registration not found for Munq.Test.IFoo"); } }
public void NonGenericNamelessGetRegistrationReturnTheExpectedRegistration() { using (var iocContainer = new IocContainer()) { var expectedRegistration = iocContainer.Register(typeof(IFoo), c => new Foo1()); var result = iocContainer.GetRegistration<IFoo>(); Verify.That(result).IsNotNull() .IsTheSameObjectAs(expectedRegistration); } }
public void CanRemoveRegistration() { using (var iocContainer = new IocContainer()) { var reg = iocContainer.Register<IFoo>(c => new Foo1()); var result = iocContainer.GetRegistration<IFoo>(); Verify.That(reg).IsTheSameObjectAs(result); iocContainer.Remove(reg); Verify.TheExpectedException(typeof(KeyNotFoundException)).IsThrownWhen( () => result = iocContainer.GetRegistration<IFoo>() ); } }