public void ResolveAndRegisterInstance() { INDOContainer container = new NDOContainer(); var car1 = container.ResolveOrRegisterInstance <ICar>("bmw", _ => new BMW()); var car2 = container.ResolveOrRegisterInstance <ICar>("bmw", _ => new BMW()); Assert.AreSame(car1, car2); var car3 = container.ResolveOrRegisterInstance <ICar>("ford", _ => new Ford()); Assert.AreNotSame(car1, car3); var car4 = container.ResolveOrRegisterInstance <ICar>("bmw2", _ => new BMW()); Assert.AreNotSame(car1, car4); }
public void ResolveAndRegisterInstanceWithFactory() { INDOContainer container = new NDOContainer(); container.ResolveOrRegisterInstance("bmw", _ => new BMW()); var bmw = container.Resolve(typeof(BMW), "bmw"); Assert.IsNotNull(bmw); Assert.AreEqual(typeof(BMW), bmw.GetType()); var bmw2 = container.Resolve(typeof(BMW), "bmw"); Assert.AreSame(bmw, bmw2); }