Exemple #1
0
        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);
        }
Exemple #3
0
        public void Create_ReturnsNonNull()
        {
            // Arrange
            IJobActivator product = CreateProductUnderTest();

            // Act
            object instance = product.CreateInstance <object>();

            // Assert
            Assert.NotNull(instance);
        }
Exemple #4
0
        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>());
        }
Exemple #5
0
        public void Create_InjectsDependencies()
        {
            // Arrange
            IJobActivator product = CreateProductUnderTest();

            // Act
            var instance = product.CreateInstance <SampleFunctions>();

            // Assert
            Assert.NotNull(instance.SampleServiceA);
            Assert.NotNull(instance.SampleServiceB);
        }
Exemple #6
0
 public TReflected Create()
 {
     return(_activator.CreateInstance <TReflected>());
 }