/// <summary>
        /// Creates an instance of the specified generic type argument, <typeparamref name="T"/>, to be used as the target of the invocation.
        /// </summary>
        /// <typeparam name="T">The type of the instance to create.</typeparam>
        /// <param name="activator">The <see cref="IFunctionActivator"/> instance to use when creating the instance.</param>
        /// <param name="context">The <see cref="FunctionContext"/> for the invocation triggering the instance creation.</param>
        /// <returns>The created instance.</returns>
        public static T?CreateInstance <T>(this IFunctionActivator activator, FunctionContext context)
            where T : class
        {
            if (activator is null)
            {
                throw new ArgumentNullException(nameof(activator));
            }

            return(activator.CreateInstance(typeof(T), context) as T);
        }
        public void Create_ReturnsNull()
        {
            // Arrange
            IFunctionActivator product = NullFunctionActivator.Instance;

            // Act
            object instance = product.CreateInstance(typeof(object), new TestFunctionContext());

            // Assert
            Assert.Null(instance);
        }
예제 #3
0
        public void Create_ReturnsNull()
        {
            // Arrange
            IFunctionActivator product = NullFunctionActivator.Instance;

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

            // Assert
            Assert.Null(instance);
        }