public TestJob(BackgroundJobDependency backgroundJobDependency, UniqueDependency uniqueDependency, ObjectDependsOnSameDependency sameDependencyObject) { this.BackgroundJobDependency = backgroundJobDependency; this.UniqueDependency = uniqueDependency; this.SameDependencyObject = sameDependencyObject; }
public void ActivateJob_Resolves_Instance_Using_StructureMap() { var dependency = new BackgroundJobDependency(); this.container.Inject(dependency); var activator = CreateActivator(); var result = activator.ActivateJob(typeof(BackgroundJobDependency)); result.ShouldBe(dependency); }
public void Instance_Registered_With_Singleton_Scope_Is_Not_Disposed_On_Scope_Disposal() { var disposable = new BackgroundJobDependency(); _container.Configure(expression => expression.For<BackgroundJobDependency>().Singleton().Use(disposable)); var activator = CreateActivator(); using (var scope = activator.BeginScope()) { var instance = scope.Resolve(typeof(BackgroundJobDependency)); Assert.Same(instance, disposable); Assert.False(((BackgroundJobDependency)instance).Disposed); } Assert.False(disposable.Disposed); }
public void Instance_Registered_With_Transient_Scope_Is_Not_Disposed_On_Scope_Disposal() { var disposable = new BackgroundJobDependency(); _container.Inject(disposable); var activator = CreateActivator(); using (var scope = activator.BeginScope()) { var instance = scope.Resolve(typeof(BackgroundJobDependency)); Assert.Same(instance, disposable); Assert.False(((BackgroundJobDependency)instance).Disposed); } Assert.False(disposable.Disposed); }
public void Instance_Registered_With_Singleton_Scope_Is_Not_Disposed_On_Scope_Disposal() { var disposable = new BackgroundJobDependency(); _container.Configure(expression => expression.For <BackgroundJobDependency>().Singleton().Use(disposable)); var activator = CreateActivator(); using (var scope = activator.BeginScope()) { var instance = scope.Resolve(typeof(BackgroundJobDependency)); Assert.Same(instance, disposable); Assert.False(((BackgroundJobDependency)instance).Disposed); } Assert.False(disposable.Disposed); }
public void Instance_Registered_With_Transient_Scope_Is_Not_Disposed_On_Scope_Disposal() { var disposable = new BackgroundJobDependency(); _container.Inject(disposable); var activator = CreateActivator(); using (var scope = activator.BeginScope()) { var instance = scope.Resolve(typeof(BackgroundJobDependency)); Assert.Same(instance, disposable); Assert.False(((BackgroundJobDependency)instance).Disposed); } Assert.False(disposable.Disposed); }
public void Implicitly_Singleton_Scoped_Instance_Is_Not_Disposed_When_Job_Scope_Is_Disposed() { var existingInstance = new BackgroundJobDependency(); this.container.Configure(c => c.For <BackgroundJobDependency>().Use(existingInstance)); using (var scope = BeginJobScope()) { var disposable = scope.Resolve(typeof(BackgroundJobDependency)) as BackgroundJobDependency; disposable.ShouldBe(existingInstance); disposable.Disposed.ShouldBeFalse(); } existingInstance.Disposed.ShouldBeFalse(); }
public void Singleton_Scoped_Instance_Is_Not_Disposed_When_Job_Scope_Is_Disposed() { var disposable = new BackgroundJobDependency(); this.container.Configure(c => c.For <BackgroundJobDependency>().Singleton().Use(disposable)); using (var scope = BeginJobScope()) { var instance = scope.Resolve(typeof(BackgroundJobDependency)) as BackgroundJobDependency; instance.ShouldBe(disposable); instance.Disposed.ShouldBeFalse(); } // Singletons should live on after the scope is disposed disposable.Disposed.ShouldBeFalse(); }
public TestJob(BackgroundJobDependency backgroundJobDependency, UniqueDependency uniqueDependency, ObjectDependsOnSameDependency sameDependencyObject) { BackgroundJobDependency = backgroundJobDependency; UniqueDependency = uniqueDependency; SameDependencyObject = sameDependencyObject; }
public ObjectDependsOnSameDependency(BackgroundJobDependency backgroundJobDependency, UniqueDependency uniqueDependency) { BackgroundJobDependency = backgroundJobDependency; UniqueDependency = uniqueDependency; }
public ObjectDependsOnSameDependency(BackgroundJobDependency backgroundJobDependency, UniqueDependency uniqueDependency) { BackgroundJobDependency = backgroundJobDependency; UniqueDependency = uniqueDependency; }