public DependencyHolder(IDIContainer container, Type dependencyType) { this.Container = container; this.DependencyType = dependencyType; this.InstanceType = InstanceType.Static; this.LifetimeManager = InstanceLifetimeManager.GetInstanceLifetimeManager(this.Container, DependencyType, this.InstanceType); }
public void InstanceLifetimeManager_GetInstanceLifetimeManager_Test() { //arrage Mock <IDIContainer> mockContainer = new Mock <IDIContainer>(); InstanceLifetimeManager localInstanceLifetimeManager, staticInstanceLifetimeManager, invalidLifetimeManager; //act localInstanceLifetimeManager = InstanceLifetimeManager.GetInstanceLifetimeManager(mockContainer.Object, typeof(foo), InstanceType.Local); staticInstanceLifetimeManager = InstanceLifetimeManager.GetInstanceLifetimeManager(mockContainer.Object, typeof(foo), InstanceType.Static); invalidLifetimeManager = InstanceLifetimeManager.GetInstanceLifetimeManager(mockContainer.Object, typeof(foo), InstanceType.Invalid); //assert Assert.IsInstanceOfType(localInstanceLifetimeManager, typeof(LocalInstanceLifetimeManager)); Assert.IsInstanceOfType(staticInstanceLifetimeManager, typeof(StaticInstanceLifetimeManager)); Assert.IsNull(invalidLifetimeManager); }