public void Create_ReturnsNewInstance() { // Arrange IJobActivator product = CreateProductUnderTest(); object originalInstance = product.CreateInstance <object>(); // Act object instance = product.CreateInstance <object>(); // Assert Assert.NotNull(instance); Assert.NotSame(originalInstance, instance); }
// Start listeners and run until the Task source is set. public async Task <TResult> RunTriggerAsync <TResult>(TaskCompletionSource <TResult> taskSource = null) { // Program was registered with the job activator, so we can get it TProgram prog = _jobActivator.CreateInstance <TProgram>(); if (taskSource == null) { var progResult = prog as IProgramWithResult <TResult>; taskSource = new TaskCompletionSource <TResult>(); progResult.TaskSource = taskSource; } TResult result = default(TResult); // Act using (this) { try { await this.StartAsync(); // Assert result = await TestHelpers.AwaitWithTimeout(taskSource); } finally { await this.StopAsync(); } } return(result); }
public void Create_ReturnsNonNull() { // Arrange IJobActivator product = CreateProductUnderTest(); // Act object instance = product.CreateInstance <object>(); // Assert Assert.NotNull(instance); }
public ActivatorInstanceFactory(IJobActivator activator) { if (activator == null) { throw new ArgumentNullException(nameof(activator)); } _createInstance = activator is IJobActivatorEx activatorEx ? new Func <IFunctionInstanceEx, T>(i => activatorEx.CreateInstance <T>(i)) : new Func <IFunctionInstanceEx, T>(i => activator.CreateInstance <T>()); }
public void Create_InjectsDependencies() { // Arrange IJobActivator product = CreateProductUnderTest(); // Act var instance = product.CreateInstance <SampleFunctions>(); // Assert Assert.NotNull(instance.SampleServiceA); Assert.NotNull(instance.SampleServiceB); }
public TReflected Create() { return(_activator.CreateInstance <TReflected>()); }