public void RegisterType_CallContainerRegisterMethodLifeCycleSingleton_TypeRegisteredSucessful() { //Arrange IContainer container = new Container(); Helper1 help1 = new Helper1(); //Act container.Register <IHelper1, Helper1>(LifeCycle.Singleton); var actualType1 = container.Resolve <IHelper1>(); //Assert Assert.IsType(help1.GetType(), actualType1); }
public void RegisterType_CallContainer_TypesAreRegisteredAndResolvedBytype() { //Arrange IContainer container = new Container(); IHelper1 help1 = new Helper1(); //Act container.Register <IHelper1, Helper1>(); var actualType1 = container.Resolve(typeof(IHelper1)); //Assert Assert.IsType(help1.GetType(), actualType1); }
public void RegisterType_TwoDifferentImplementationsTwoDifferentInterfaces_TypesAreRegisteredAndResolved() { //Arrange IContainer container = new Container(); Helper1 help1 = new Helper1(); Helper2 help2 = new Helper2(); //Act container.Register <IHelper1, Helper1>(); container.Register <IHelper2, Helper2>(); var actualType1 = container.Resolve <IHelper1>(); var actualType2 = container.Resolve <IHelper2>(); //Assert Assert.IsType(help1.GetType(), actualType1); Assert.IsType(help2.GetType(), actualType2); }
public void RegisterType_OneInterfaceTwoDifferentImplementations_TypesAreRegisteredAndResolvedByType() { //Arrange Container container = new Container(); IHelper1 help1 = new Helper1(); IHelper1 help2 = new Helper2(); //Act container.Register <IHelper1, Helper1>(); container.Register <IHelper1, Helper2>(); List <object> actualTypes = container.ResolveAll(typeof(IHelper1)).ToList(); //Assert Assert.NotNull(actualTypes); Assert.Equal(help1.GetType().FullName, actualTypes[0].GetType().FullName); Assert.Equal(help2.GetType().FullName, actualTypes[1].GetType().FullName); }