public void Install(IContainerGenerator containerGenerator) { containerGenerator.Register <TriggerFileManager>().As <ITriggerFileManager>().WithLifestyle(RegistrationLifestyleType.Singleton); containerGenerator.Register <CacheAccessor>().As <ICacheAccessor>().WithLifestyle(RegistrationLifestyleType.Singleton); containerGenerator.Register(typeof(ObjectCache <>)).As(typeof(IObjectCache <>)).WithLifestyle(RegistrationLifestyleType.Transient); }
public void CanResolveInstance() { service.Register <IRandomGUIDProvider, RandomGUIDProvider>(); IRandomGUIDProvider result = container.Resolve <IRandomGUIDProvider>(); Assert.IsNotNull(result); }
public void Install(IContainerGenerator container) { container.Register <Container>().As <IContainer>().WithLifestyle(RegistrationLifestyleType.Transient); container.Register <ContainerGenerator>().As <IContainerGenerator>().WithLifestyle(RegistrationLifestyleType.Transient); container.Register(typeof(RegistrationResult <,>)).As(typeof(IRegistrationResult <,>)).WithLifestyle(RegistrationLifestyleType.Transient); container.Register <ServiceLocator>().As <IServiceLocator>().WithLifestyle(RegistrationLifestyleType.Singleton); }
public void Can_Register_To_Container_By_Type_With_Generic_Method_Generate_Container_And_Resolve() { _sut.Register <TestClass>().As <ITestInterface>(); var container = _sut.GenerateContainer(); var result = container.Resolve <ITestInterface>(); Assert.IsType <TestClass>(result); }
public void Singleton_Registration_Creates_One_And_Only_One_Instance() { _sut.Register <TestClass>().As <ITestInterface>().WithLifestyle(RegistrationLifestyleType.Singleton); var container = _sut.GenerateContainer(); var v1 = container.Resolve <ITestInterface>(); var v2 = container.Resolve <ITestInterface>(); var v3 = container.Resolve <ITestInterface>(); Assert.Same(v1, v2); Assert.Same(v2, v3); Assert.Same(v1, v3); }
public void TestRegisterWithoutParams() { bool result = service.Register <ITestInterface, TestImplementation>(); Assert.AreEqual(true, result); }
public void Install(IContainerGenerator container) { container.Register <Clock>().As <IClock>(); container.Register <RandomizationHelper>().As <IRandomizationHelper>(); container.Register(typeof(ReflectionHelper <>)).As(typeof(IReflectionHelper <>)); }
public void Install(IContainerGenerator containerGenerator) { containerGenerator.Register <DatabaseKeyManager>().As <IDatabaseKeyManager>().WithLifestyle(RegistrationLifestyleType.Singleton); containerGenerator.Register <TranConn>().As <ITranConn>().WithLifestyle(RegistrationLifestyleType.Transient);; }