Ejemplo n.º 1
0
        public void ShouldNotAllowOverrideRegistrationAfterResolve()
        {
            // given

            var container = new ObjectContainer();
            container.RegisterTypeAs<VerySimpleClass, IInterface1>();
            container.Resolve<IInterface1>();
            var instance = new SimpleClassWithDefaultCtor();

            // when

            container.RegisterInstanceAs<IInterface1>(instance);
        }
Ejemplo n.º 2
0
        public void ShouldAllowOverrideRegistrationBeforeResolve()
        {
            // given

            var container = new ObjectContainer();
            container.RegisterTypeAs<VerySimpleClass, IInterface1>();
            var instance = new SimpleClassWithDefaultCtor();

            // when

            container.RegisterInstanceAs<IInterface1>(instance);

            // then

            var obj = container.Resolve<IInterface1>();
            Assert.IsNotNull(obj);
            Assert.IsInstanceOf(typeof(SimpleClassWithDefaultCtor), obj);
        }