public async Task ToFunctionTrigger_Codeless_ReturnsExpected()
        {
            var functionMetadata = new FunctionMetadata
            {
                Name = "TestFunction1"
            };
            var options = new ScriptJobHostOptions
            {
                RootScriptPath = _testRootScriptPath
            };

            functionMetadata.SetIsCodeless(true);

            JObject functionConfig = JObject.Parse(_sampleBindingsJson);
            JArray  bindingArray   = (JArray)functionConfig["bindings"];

            foreach (JObject binding in bindingArray)
            {
                BindingMetadata bindingMetadata = BindingMetadata.Create(binding);
                functionMetadata.Bindings.Add(bindingMetadata);
            }

            var result = await functionMetadata.ToFunctionTrigger(options);

            Assert.Equal("TestFunction1", result["functionName"].Value <string>());
            Assert.Equal("httpTrigger", result["type"].Value <string>());

            // make sure original binding did not change
            Assert.Null(functionMetadata.Bindings[0].Raw["functionName"]?.Value <string>());
            Assert.Equal("httpTrigger", functionMetadata.Bindings[0].Raw["type"].Value <string>());
        }
Ejemplo n.º 2
0
        public async Task ToFunctionTrigger_Codeless_ReturnsExpected()
        {
            var functionMetadata = new FunctionMetadata
            {
                Name = "TestFunction1"
            };
            var options = new ScriptJobHostOptions
            {
                RootScriptPath = _testRootScriptPath
            };

            functionMetadata.SetIsCodeless(true);

            AddSampleBindings(functionMetadata);

            var result = await functionMetadata.ToFunctionTrigger(options);

            Assert.Equal("TestFunction1", result["functionName"].Value <string>());
            Assert.Equal("httpTrigger", result["type"].Value <string>());

            // make sure original binding did not change
            Assert.Null(functionMetadata.Bindings[0].Raw["functionName"]?.Value <string>());
            Assert.Equal("httpTrigger", functionMetadata.Bindings[0].Raw["type"].Value <string>());
        }