public void MakeInstance_TypeRequiresRegisteredSingleton_ShouldCreateInstance() { var container = new DIContainer(); var classWithSingleConstructor = new ClassWithSingleConstructor(); container.RegisterSingleton <ClassWithSingleConstructor>(classWithSingleConstructor); var instance = container.MakeInstance(typeof(ClassExpectingInstance)); Assert.IsNotNull(instance); Assert.IsInstanceOfType(instance, typeof(ClassExpectingInstance)); }
public void RegisterSingleton_ContractHasAlreadyBeenRegistered_ShouldRegisterNewInstance() { var container = new DIContainer(); var instance1 = new ClassWithSingleConstructor(); var instance2 = new ClassWithSingleConstructor(); container.RegisterSingleton(typeof(ClassWithSingleConstructor), instance1); container.RegisterSingleton(typeof(ClassWithSingleConstructor), instance2); var actualInstance = container.Get <ClassWithSingleConstructor>(); Assert.AreEqual(instance2, actualInstance); }