Exemplo n.º 1
0
 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");
     }
 }
Exemplo n.º 2
0
        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);
            }
        }
Exemplo n.º 3
0
        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>()
                );
            }
        }