public void TestMultiPocoDispatch() { var payload0 = new Payload { val1 = 100 }; var payload1 = new Payload { val1 = 200 }; var e0 = new FakeQueueData { Message = JsonConvert.SerializeObject(payload0) }; var e1 = new FakeQueueData { Message = JsonConvert.SerializeObject(payload1) }; var items = Run <FunctionsMultiPoco>(e0, e1); Assert.Equal(2, items.Length); // this trigger strongly binds to a poco and adds Payload.val1 Assert.Equal(payload0.val1, ((Payload)items[0]).val1); Assert.Equal(payload1.val1, ((Payload)items[1]).val1); }
public async Task TestTriggerAdapter() { IHost host = new HostBuilder() .ConfigureDefaultTestHost <Prog>(b => { b.AddExtension <FakeQueueClient>(); b.AddExtension <Ext>(); }) .Build(); var args = new Dictionary <string, object>(); args["data"] = new FakeQueueData { Message = "15" }; // Test various converters. await host.GetJobHost <Prog>().CallAsync("FuncAsString", args); Assert.Equal("15", Prog._value); await host.GetJobHost <Prog>().CallAsync("FuncAsInt", args); Assert.Equal(15, Prog._value); }
public void TestSingleStringDispatch() { var e0 = new FakeQueueData { Message = "xyz" }; var items = Run <FunctionsSingleString>(e0); Assert.Single(items); // this trigger strongly binds to a poco and adds Payload.val1 Assert.Equal(e0.Message, items[0]); }
public async Task TestNoStringTriggerAdapter() { var queueClient = new FakeQueueClient(); var config = TestHelpers.NewConfig <ProgNoString>(new ExtNoStringConverter(), queueClient); var host = new JobHost(config); var args = new Dictionary <string, object>(); args["data"] = new FakeQueueData { Message = "15" }; await host.CallAsync("FuncAsInt", args); Assert.Equal(15, ProgNoString._value); }
public void TestByteArrayDispatch() { var e0 = new FakeQueueData { Message = "ABC" }; var items = Run <FunctionsByteArray>(c => c.SetConverters = AddItem2ByteArrayConverter, e0); Assert.Single(items); // This uses the Item --> byte[] converter. Dispatch as a single item. // Received as 1 object, a byte[]. var bytes = System.Text.Encoding.UTF8.GetBytes(e0.Message); Assert.Equal(bytes, items[0]); }
public void TestSinglePocoDispatch() { var payload = new Payload { val1 = 123 }; var e0 = new FakeQueueData { Message = JsonConvert.SerializeObject(payload) }; var items = Run <FunctionsSinglePoco>(e0); Assert.Single(items); // this trigger strongly binds to a poco and adds Payload.val1 Assert.Equal(payload.val1, items[0]); }
public void TestFunctionsOutputUsesParams() { var payload = new Payload { val1 = 123 }; var e0 = new FakeQueueData { Message = JsonConvert.SerializeObject(payload) }; var items = Run <FunctionsOutputUsesParams>(e0); Assert.Single(items); // this trigger strongly binds to a poco and adds Payload.val1 var d = (FakeQueueData)(items[0]); Assert.Equal("x123", d.ExtraPropertery); Assert.Equal("abc", d.Message); }
public void TestMultiDispatch() { var e0 = new FakeQueueData { Message = "first", ExtraPropertery = "extra" }; var e1 = new FakeQueueData { Message = "second", ExtraPropertery = "extra2" }; var items = Run <FunctionMulti>(e0, e1); Assert.Equal(2, items.Length); // For a direct binding, should be the same instance and skip serialization altogether. Assert.True(object.ReferenceEquals(e0, items[0])); Assert.True(object.ReferenceEquals(e1, items[1])); }
public void SingleTrigger([FakeQueueTrigger] FakeQueueData single) { _collected.Add(single); this.Finished(); }