public void ManualTest()
        {
            JobHostConfiguration config = new JobHostConfiguration();

            config.UseScriptExtensions();
            TestTraceWriter traceWriter      = new TestTraceWriter(TraceLevel.Verbose);
            JObject         hostMetadata     = new JObject();
            var             provider         = new GeneralScriptBindingProvider(config, hostMetadata, traceWriter);
            var             metadataProvider = new JobHost(config).CreateMetadataProvider();

            provider.CompleteInitialization(metadataProvider);

            JObject bindingMetadata = new JObject
            {
                { "type", "manualTrigger" },
                { "name", "test" },
                { "direction", "in" }
            };

            ScriptBindingContext context = new ScriptBindingContext(bindingMetadata);
            ScriptBinding        binding = null;
            bool created = provider.TryCreate(context, out binding);

            Assert.True(created);
            Assert.Equal(typeof(string), binding.DefaultType);

            var attr = binding.GetAttributes()[0];

            Assert.IsType <ManualTriggerAttribute>(attr);
        }
        public void ManualTest()
        {
            var metadataProvider = TestHelpers.GetDefaultHost()
                                   .Services.GetService <IJobHostMetadataProvider>();

            var provider = new GeneralScriptBindingProvider(NullLogger <GeneralScriptBindingProvider> .Instance, metadataProvider);

            JObject bindingMetadata = new JObject
            {
                { "type", "manualTrigger" },
                { "name", "test" },
                { "direction", "in" }
            };

            ScriptBindingContext context = new ScriptBindingContext(bindingMetadata);
            ScriptBinding        binding = null;
            bool created = provider.TryCreate(context, out binding);

            Assert.True(created);
            Assert.Equal(typeof(string), binding.DefaultType);

            var attr = binding.GetAttributes()[0];

            Assert.IsType <ManualTriggerAttribute>(attr);
        }
        public void TryCreate_NoMatchingMetadata_DoesNotCreateBinding()
        {
            JObject bindingMetadata = new JObject
            {
                { "type", "unknown" },
                { "name", "test" },
                { "direction", "out" }
            };
            ScriptBindingContext context = new ScriptBindingContext(bindingMetadata);
            ScriptBinding        binding = null;

            var  mockMetadataProvider = new Mock <IJobHostMetadataProvider>();
            var  provider             = new GeneralScriptBindingProvider(NullLogger <GeneralScriptBindingProvider> .Instance, mockMetadataProvider.Object);
            bool created = provider.TryCreate(context, out binding);

            Assert.False(created);
            Assert.Null(binding);
        }
Beispiel #4
0
        public void TryCreate_NoMatchingMetadata_DoesNotCreateBinding()
        {
            JObject bindingMetadata = new JObject
            {
                { "type", "unknown" },
                { "name", "test" },
                { "direction", "out" }
            };
            ScriptBindingContext context = new ScriptBindingContext(bindingMetadata);
            ScriptBinding        binding = null;
            JobHostConfiguration config  = new JobHostConfiguration();

            config.UseScriptExtensions();
            JObject hostMetadata     = new JObject();
            var     provider         = new GeneralScriptBindingProvider(config, hostMetadata, null);
            var     metadataProvider = new JobHost(config).CreateMetadataProvider();

            provider.CompleteInitialization(metadataProvider);
            bool created = provider.TryCreate(context, out binding);

            Assert.False(created);
            Assert.Null(binding);
        }