public void Test()
        {
            JobHostConfiguration config = new JobHostConfiguration()
            {
                TypeLocator = new FakeTypeLocator(typeof(Functions))
            };

            FakeQueueClient    client     = new FakeQueueClient();
            IExtensionRegistry extensions = config.GetService <IExtensionRegistry>();

            extensions.RegisterExtension <IExtensionConfigProvider>(client);

            JobHost host = new JobHost(config);

            // Single items
            var p1 = InvokeJson <Payload>(host, client, "SendOnePoco");

            Assert.Equal(1, p1.Length);
            Assert.Equal(123, p1[0].val1);

            var p2 = Invoke(host, client, "SendOneNative");

            Assert.Equal(1, p2.Length);
            Assert.Equal("message", p2[0].Message);
            Assert.Equal("extra", p2[0].ExtraPropertery);

            var p3 = Invoke(host, client, "SendOneString");

            Assert.Equal(1, p3.Length);
            Assert.Equal("stringvalue", p3[0].Message);

            foreach (string methodName in new string[] { "SendDontQueue", "SendArrayNull", "SendArrayLen0" })
            {
                var p6 = Invoke(host, client, methodName);
                Assert.Equal(0, p6.Length);
            }

            // batching
            foreach (string methodName in new string[] {
                "SendSyncCollectorBytes", "SendArrayString", "SendSyncCollectorString", "SendAsyncCollectorString", "SendCollectorNative"
            })
            {
                var p4 = Invoke(host, client, methodName);
                Assert.Equal(2, p4.Length);
                Assert.Equal("first", p4[0].Message);
                Assert.Equal("second", p4[1].Message);
            }

            foreach (string methodName in new string[] { "SendCollectorPoco", "SendArrayPoco" })
            {
                var p5 = InvokeJson <Payload>(host, client, methodName);
                Assert.Equal(2, p5.Length);
                Assert.Equal(100, p5[0].val1);
                Assert.Equal(200, p5[1].val1);
            }
        }
        static FakeQueueData[] Invoke(JobHost host, FakeQueueClient client, string name)
        {
            var method = typeof(Functions).GetMethod(name, BindingFlags.Public | BindingFlags.Static);

            host.Call(method);

            var data = client._items.ToArray();

            client._items.Clear();
            return(data);
        }
        static T[] InvokeJson <T>(JobHost host, FakeQueueClient client, string name)
        {
            var method = typeof(Functions).GetMethod(name, BindingFlags.Public | BindingFlags.Static);

            host.Call(method);

            var data = client._items.ToArray();

            var obj = Array.ConvertAll(data, x => JsonConvert.DeserializeObject <T>(x.Message));

            client._items.Clear();
            return(obj);
        }
 public FakeQueueTriggerBindingProvider(FakeQueueClient client, IConverterManager converterManager)
 {
     _client           = client;
     _converterManager = converterManager;
 }
Exemple #5
0
 public FakeQueueListener(ITriggeredFunctionExecutor executor, FakeQueueClient client, bool singleDispatch)
 {
     this._executor       = executor;
     this._singleDispatch = singleDispatch;
     this._client         = client;
 }