コード例 #1
0
        // Helper to do the indexing.
        private static Tuple <FunctionDescriptor, IFunctionDefinition> IndexMethod(string methodName, INameResolver nameResolver = null)
        {
            MethodInfo method = typeof(FunctionIndexerIntegrationTests).GetMethod(methodName, BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);

            Assert.NotNull(method);

            FunctionIndexer indexer = FunctionIndexerFactory.Create(CloudStorageAccount.DevelopmentStorageAccount,
                                                                    nameResolver);

            Tuple <FunctionDescriptor, IFunctionDefinition> indexEntry = null;
            Mock <IFunctionIndexCollector> indexMock = new Mock <IFunctionIndexCollector>(MockBehavior.Strict);

            indexMock
            .Setup((i) => i.Add(
                       It.IsAny <IFunctionDefinition>(),
                       It.IsAny <FunctionDescriptor>(),
                       It.IsAny <MethodInfo>()))
            .Callback <IFunctionDefinition, FunctionDescriptor, MethodInfo>(
                (ifd, fd, i) => indexEntry = Tuple.Create(fd, ifd));
            IFunctionIndexCollector index = indexMock.Object;

            indexer.IndexMethodAsync(method, index, CancellationToken.None).GetAwaiter().GetResult();

            return(indexEntry);
        }
コード例 #2
0
        public void IsJobMethod_ReturnsTrue_IfMethodHasJobParameterAttributes_FromExtensionAssemblies()
        {
            // Arrange
            Mock <IFunctionIndex> indexMock  = new Mock <IFunctionIndex>();
            IExtensionRegistry    extensions = new DefaultExtensionRegistry();

            extensions.RegisterExtension <ITriggerBindingProvider>(new TestExtensionTriggerBindingProvider());
            extensions.RegisterExtension <IBindingProvider>(new TestExtensionBindingProvider());
            FunctionIndexer product = FunctionIndexerFactory.Create(extensionRegistry: extensions);

            // Act
            bool actual = product.IsJobMethod(typeof(FunctionIndexerTests).GetMethod("MethodWithExtensionJobParameterAttributes"));

            // Verify
            Assert.Equal(true, actual);
        }
コード例 #3
0
        public async Task FSharpTasks_AreCorrectlyIndexed()
        {
            // Arrange
            MethodInfo method = typeof(FSharpFunctions.TestFunction).GetMethod("TaskTest",
                                                                               BindingFlags.Static | BindingFlags.Public);

            Assert.NotNull(method); // Guard

            FunctionIndexer indexer        = FunctionIndexerFactory.Create(CloudStorageAccount.DevelopmentStorageAccount);
            var             indexCollector = new TestIndexCollector();

            // Act & Assert
            await indexer.IndexMethodAsyncCore(method, indexCollector, CancellationToken.None);

            Assert.Contains(indexCollector.Functions, d => string.Equals(d.ShortName, "TestFunction.TaskTest"));
        }
コード例 #4
0
        public void BindNonStringableParameter_FailsIndexing()
        {
            // Arrange
            MethodInfo method = typeof(DataBindingFunctionalTests).GetMethod("TryToBindNonStringableParameter",
                                                                             BindingFlags.Static | BindingFlags.NonPublic);

            Assert.NotNull(method); // Guard

            FunctionIndexer         indexer   = FunctionIndexerFactory.Create(CloudStorageAccount.DevelopmentStorageAccount);
            IFunctionIndexCollector stubIndex = new Mock <IFunctionIndexCollector>().Object;

            // Act & Assert
            Exception exception = Assert.Throws <InvalidOperationException>(
                () => indexer.IndexMethodAsyncCore(method, stubIndex, CancellationToken.None).GetAwaiter().GetResult());

            Assert.Equal("Can't bind parameter 'doubleValue' to type 'System.String'.",
                         exception.Message);
        }
コード例 #5
0
 private static FunctionIndexer CreateProductUnderTest()
 {
     return(FunctionIndexerFactory.Create());
 }
コード例 #6
0
 private static FunctionIndexer CreateProductUnderTest(TraceWriter traceWriter = null, ILoggerFactory loggerFactory = null)
 {
     return(FunctionIndexerFactory.Create(traceWriter: traceWriter, loggerFactory: loggerFactory));
 }
コード例 #7
0
 private static FunctionIndexer CreateProductUnderTest(ILoggerFactory loggerFactory = null)
 {
     return(FunctionIndexerFactory.Create(loggerFactory: loggerFactory));
 }