public void Activate() { var activator = new StashboxJobActivator(new StashboxContainer().Register <TestJob>()); var job = activator.ActivateJob(typeof(TestJob)); job.ShouldNotBeNull(); }
public void ActivateWithDependency() { var activator = new StashboxJobActivator(new StashboxContainer() .Register <TestJobWithDependency>() .Register <Dependency>()); var job = activator.ActivateJob(typeof(TestJobWithDependency)) as TestJobWithDependency; job.ShouldNotBeNull(); job.Dependency.ShouldNotBeNull(); }
public void ActivateWithScope() { var activator = new StashboxJobActivator(new StashboxContainer() .Register <TestJobWithDependency>() .RegisterScoped <Dependency>()); TestJobWithDependency job; using (var scope = activator.BeginScope((JobActivatorContext)null)) { job = scope.Resolve(typeof(TestJobWithDependency)) as TestJobWithDependency; job.Dependency.Disposed.ShouldBeFalse(); } job.Dependency.Disposed.ShouldBeTrue(); }