public async Task VerifyDurableTaskHubNameIsAdded()
        {
            var vars = new Dictionary <string, string>
            {
                { EnvironmentSettingNames.WebSiteAuthEncryptionKey, TestHelpers.GenerateKeyHexString() },
                { EnvironmentSettingNames.AzureWebsiteHostName, "appName.azurewebsites.net" }
            };

            using (var env = new TestScopedEnvironmentVariable(vars))
            {
                // Setup
                const string expectedSyncTriggersPayload = "[{\"authLevel\":\"anonymous\",\"type\":\"httpTrigger\",\"direction\":\"in\",\"name\":\"req\",\"functionName\":\"function1\"}," +
                                                           "{\"name\":\"myQueueItem\",\"type\":\"orchestrationTrigger\",\"direction\":\"in\",\"queueName\":\"myqueue-items\",\"connection\":\"DurableStorage\",\"functionName\":\"function2\",\"taskHubName\":\"TestHubValue\"}," +
                                                           "{\"name\":\"myQueueItem\",\"type\":\"activityTrigger\",\"direction\":\"in\",\"queueName\":\"myqueue-items\",\"connection\":\"DurableStorage\",\"functionName\":\"function3\",\"taskHubName\":\"TestHubValue\"}]";
                var settings       = CreateWebSettings();
                var fileSystem     = CreateFileSystem(settings.ScriptPath);
                var loggerFactory  = MockNullLogerFactory.CreateLoggerFactory();
                var contentBuilder = new StringBuilder();
                var httpClient     = CreateHttpClient(contentBuilder);
                var webManager     = new WebFunctionsManager(new OptionsWrapper <ScriptApplicationHostOptions>(settings), new OptionsWrapper <LanguageWorkerOptions>(CreateLanguageWorkerConfigSettings()), loggerFactory, httpClient);

                FileUtility.Instance = fileSystem;

                // Act
                (var success, var error) = await webManager.TrySyncTriggers();

                var content = contentBuilder.ToString();

                // Assert
                Assert.True(success, "SyncTriggers should return success true");
                Assert.True(string.IsNullOrEmpty(error), "Error should be null or empty");
                Assert.Equal(expectedSyncTriggersPayload, content);
            }
        }
예제 #2
0
        public async Task VerifyDurableTaskHubNameIsAdded()
        {
            // Setup
            const string expectedSyncTriggersPayload = "[{\"authLevel\":\"anonymous\",\"type\":\"httpTrigger\",\"direction\":\"in\",\"name\":\"req\",\"functionName\":\"function1\"}," +
                                                       "{\"name\":\"myQueueItem\",\"type\":\"orchestrationTrigger\",\"direction\":\"in\",\"queueName\":\"myqueue-items\",\"connection\":\"DurableStorage\",\"functionName\":\"function2\",\"taskHubName\":\"TestHubValue\"}," +
                                                       "{\"name\":\"myQueueItem\",\"type\":\"activityTrigger\",\"direction\":\"in\",\"queueName\":\"myqueue-items\",\"connection\":\"DurableStorage\",\"functionName\":\"function3\",\"taskHubName\":\"TestHubValue\"}]";
            var settings       = CreateWebSettings();
            var fileSystem     = CreateFileSystem(settings.ScriptPath);
            var loggerFactory  = MockNullLogerFactory.CreateLoggerFactory();
            var contentBuilder = new StringBuilder();
            var httpClient     = CreateHttpClient(contentBuilder);
            var webManager     = new WebFunctionsManager(settings, loggerFactory, httpClient);

            FileUtility.Instance = fileSystem;

            Environment.SetEnvironmentVariable(EnvironmentSettingNames.WebSiteAuthEncryptionKey, TestHelpers.GenerateKeyHexString());
            Environment.SetEnvironmentVariable("WEBSITE_SITE_NAME", "appName");

            // Act
            (var success, var error) = await webManager.TrySyncTriggers();

            var content = contentBuilder.ToString();

            // Assert
            Assert.True(success, "SyncTriggers should return success true");
            Assert.True(string.IsNullOrEmpty(error), "Error should be null or empty");
            Assert.Equal(expectedSyncTriggersPayload, content);
        }