Esempio 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");
     }
 }
Esempio 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);
            }
        }
Esempio 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>()
                );
            }
        }