public static void SendOneDerivedNative([FakeQueue] out DerivedFakeQueueData output) { output = new DerivedFakeQueueData { ExtraPropertery = "extra", Message = "message", Bonus = "Bonus!" }; }
public async Task Test() { IHost host = new HostBuilder() .ConfigureDefaultTestHost <Functions>(b => { b.AddExtension <FakeQueueClient>(); }) .Build(); JobHost jobHost = host.GetJobHost(); FakeQueueClient client = host.GetExtension <FakeQueueClient>(); var p7 = await InvokeAsync(jobHost, client, "SendDirectClient"); Assert.Single(p7); Assert.Equal("abc", p7[0].Message); Assert.Equal("def", p7[0].ExtraPropertery); var p8 = await InvokeAsync(jobHost, client, "SendOneDerivedNative"); Assert.Single(p8); DerivedFakeQueueData pd8 = (DerivedFakeQueueData)p8[0]; Assert.Equal("Bonus!", pd8.Bonus); // verify derived prop that wouldn't serialize. var p9 = await InvokeAsync(jobHost, client, "SendOneOtherNative"); Assert.Single(p9); Assert.Equal("direct", p9[0].ExtraPropertery); // Set by the DirectFakeQueueData.ToEvent // Single items var p1 = await InvokeJsonAsync <Payload>(jobHost, client, "SendOnePoco"); Assert.Single(p1); Assert.Equal(123, p1[0].val1); var p2 = await InvokeAsync(jobHost, client, "SendOneNative"); Assert.Single(p2); Assert.Equal("message", p2[0].Message); Assert.Equal("extra", p2[0].ExtraPropertery); var p3 = await InvokeAsync(jobHost, client, "SendOneString"); Assert.Single(p3); Assert.Equal("stringvalue", p3[0].Message); foreach (string methodName in new string[] { "SendDontQueue", "SendArrayNull", "SendArrayLen0" }) { var p6 = await InvokeAsync(jobHost, client, methodName); Assert.Empty(p6); } // batching foreach (string methodName in new string[] { "SendSyncCollectorBytes", "SendArrayString", "SendSyncCollectorString", "SendAsyncCollectorString", "SendCollectorNative" }) { var p4 = await InvokeAsync(jobHost, 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 = await InvokeJsonAsync <Payload>(jobHost, client, methodName); Assert.Equal(2, p5.Length); Assert.Equal(100, p5[0].val1); Assert.Equal(200, p5[1].val1); } }
public void Test() { FakeQueueClient client = new FakeQueueClient(); var host = TestHelpers.NewJobHost <Functions>(client); var p7 = Invoke(host, client, "SendDirectClient"); Assert.Single(p7); Assert.Equal("abc", p7[0].Message); Assert.Equal("def", p7[0].ExtraPropertery); var p8 = Invoke(host, client, "SendOneDerivedNative"); Assert.Single(p8); DerivedFakeQueueData pd8 = (DerivedFakeQueueData)p8[0]; Assert.Equal("Bonus!", pd8.Bonus); // verify derived prop that wouldn't serialize. var p9 = Invoke(host, client, "SendOneOtherNative"); Assert.Single(p9); Assert.Equal("direct", p9[0].ExtraPropertery); // Set by the DirectFakeQueueData.ToEvent // Single items var p1 = InvokeJson <Payload>(host, client, "SendOnePoco"); Assert.Single(p1); Assert.Equal(123, p1[0].val1); var p2 = Invoke(host, client, "SendOneNative"); Assert.Single(p2); Assert.Equal("message", p2[0].Message); Assert.Equal("extra", p2[0].ExtraPropertery); var p3 = Invoke(host, client, "SendOneString"); Assert.Single(p3); Assert.Equal("stringvalue", p3[0].Message); foreach (string methodName in new string[] { "SendDontQueue", "SendArrayNull", "SendArrayLen0" }) { var p6 = Invoke(host, client, methodName); Assert.Empty(p6); } // 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); } }
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); var p8 = Invoke(host, client, "SendOneDerivedNative"); Assert.Equal(1, p8.Length); DerivedFakeQueueData pd8 = (DerivedFakeQueueData)p8[0]; Assert.Equal("Bonus!", pd8.Bonus); // verify derived prop that wouldn't serialize. var p9 = Invoke(host, client, "SendOneOtherNative"); Assert.Equal(1, p9.Length); Assert.Equal("direct", p9[0].ExtraPropertery); // Set by the DirectFakeQueueData.ToEvent // 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); } }