Ejemplo n.º 1
0
        public void ResolveOrRegisterTypeWithOverride()
        {
            INDOContainer container = new NDOContainer();

            var drv1 = container.ResolveOrRegisterType <Driver>(new ContainerControlledLifetimeManager(), "bmw", new ParameterOverride("car", new BMW()));
            var drv2 = container.ResolveOrRegisterType <Driver>(new ContainerControlledLifetimeManager(), "audi", new ParameterOverride("car", new Audi()));

            Assert.AreEqual("Running BMW - 1 mile", drv1.RunCar());
            Assert.AreEqual("Running Audi - 1 mile", drv2.RunCar());
            drv1 = container.ResolveOrRegisterType <Driver>(new ContainerControlledLifetimeManager(), "bmw", new ParameterOverride("car", new BMW()));
            drv2 = container.ResolveOrRegisterType <Driver>(new ContainerControlledLifetimeManager(), "audi", new ParameterOverride("car", new Audi()));
            Assert.AreEqual("Running BMW - 2 mile", drv1.RunCar());
            Assert.AreEqual("Running Audi - 2 mile", drv2.RunCar());
        }