public TestJob(BackgroundJobDependency backgroundJobDependency, UniqueDependency uniqueDependency, ObjectDependsOnSameDependency sameDependencyObject) { this.BackgroundJobDependency = backgroundJobDependency; this.UniqueDependency = uniqueDependency; this.SameDependencyObject = sameDependencyObject; }
public void ActivateJob_Resolves_Instance_Using_Lamar() { var dependency = new BackgroundJobDependency(); var container = new Container(c => c.For <BackgroundJobDependency>().Use(dependency)); var activator = CreateActivator(container); var result = activator.ActivateJob(typeof(BackgroundJobDependency)); result.ShouldBe(dependency); }
public void Implicitly_Singleton_Scoped_Instance_Is_Not_Disposed_When_Job_Scope_Is_Disposed() { var existingInstance = new BackgroundJobDependency(); var container = new Container(c => c.For <BackgroundJobDependency>().Use(existingInstance)); using (var scope = BeginJobScope(container)) { 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(); var container = new Container(c => c.ForSingletonOf <BackgroundJobDependency>().Use(disposable)); using (var scope = BeginJobScope(container)) { 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 ObjectDependsOnSameDependency(BackgroundJobDependency backgroundJobDependency, UniqueDependency uniqueDependency) { this.BackgroundJobDependency = backgroundJobDependency; this.UniqueDependency = uniqueDependency; }