public void RegisterType_Multipe_InstanceNotInStore() { // Assign DefaultDependencyContainer container = new DefaultDependencyContainer(this.store); // Act container.RegisteType(typeof(IMainClass), typeof(MainClass)); container.RegisteType(typeof(IMainClass), typeof(MainClass2)); container.RegisteType(typeof(IMainClass), typeof(MainClass3)); // Assert Assert.AreEqual(0, this.store.Count); }
public void Resolve_ConcreteClass_ReturnsInstance() { // Assign DefaultDependencyContainer container = new DefaultDependencyContainer(); container.RegisteType(typeof(ISubClass1), typeof(SubClass1)); container.RegisteType(typeof(IMainClass), typeof(MainClass)); container.RegisteType(typeof(ISubClass2), typeof(SubClass2)); // Act var result = container.Resolve(typeof(MainClass)); // Assert Assert.IsNotNull(result); }
public void RegisterType_Resolve_InstanceIsInStore() { // Assign DefaultDependencyContainer container = new DefaultDependencyContainer(this.store); // Act container.RegisteType(typeof(IMainClass), typeof(MainClass)); container.RegisteType(typeof(ISubClass1), typeof(SubClass1)); container.RegisteType(typeof(ISubClass2), typeof(SubClass2)); Assert.AreEqual(0, this.store.Count); container.Resolve(typeof(IMainClass)); // Assert Assert.AreEqual(3, this.store.Count); }
public void ResolveAll_ReturnsInstance() { // Assign DefaultDependencyContainer container = new DefaultDependencyContainer(); container.RegisteType(typeof(ISubClass1), typeof(SubClass1)); container.RegisteType(typeof(IMainClass), typeof(MainClass)); container.RegisteType(typeof(IMainClass), typeof(MainClass2)); container.RegisteType(typeof(IMainClass), typeof(MainClass3)); container.RegisteType(typeof(ISubClass2), typeof(SubClass2)); // Act var result = container.ResolveAll(typeof(IMainClass)); // Assert Assert.IsNotNull(result); Assert.AreEqual(3, result.Count()); }