Esempio n. 1
0
        public async Task InvokeWithCompoundBindingData()
        {
            // Verify that queue binding pattern has uppercase letters in it. These get normalized to lowercase.
            Assert.AreNotEqual(ProgramWithTriggerAndBindingData.QueueOutName, ProgramWithTriggerAndBindingData.QueueOutName.ToLower());

            IHost host = new HostBuilder()
                         .ConfigureDefaultTestHost <ProgramWithTriggerAndCompoundBindingData>(b =>
            {
                b.AddAzureStorageQueues();
                b.UseQueueService(queueServiceClient);
            })
                         .Build();

            var trigger = new ProgramWithTriggerAndCompoundBindingData.Poco
            {
                xyz   = "bad",
                prop1 = new ProgramWithTriggerAndCompoundBindingData.SubOject
                {
                    xyz = "abc"
                }
            };

            await host.GetJobHost().CallAsync <ProgramWithTriggerAndCompoundBindingData>("Func", new
            {
                triggers = QueuesModelFactory.QueueMessage("id", "receipt", JsonConvert.SerializeObject(trigger), 0)
            });

            // Now peek at messages.
            // queue name is normalized to lowercase.
            var queue = queueServiceClient.GetQueueClient("qname-abc");
            var msgs  = (await queue.ReceiveMessagesAsync(10)).Value;

            Assert.AreEqual(1, msgs.Count());
            Assert.AreEqual("123", msgs[0].MessageText);
        }
Esempio n. 2
0
        public async Task InvokeWithCompoundBindingData()
        {
            // Verify that queue binding pattern has uppercase letters in it. These get normalized to lowercase.
            Assert.NotEqual(ProgramWithTriggerAndBindingData.QueueOutName, ProgramWithTriggerAndBindingData.QueueOutName.ToLower());

            var   account = CreateFakeStorageAccount();
            IHost host    = new HostBuilder()
                            .ConfigureDefaultTestHost <ProgramWithTriggerAndCompoundBindingData>(b =>
            {
                b.UseStorage(account);
            })
                            .Build();

            var trigger = new ProgramWithTriggerAndCompoundBindingData.Poco
            {
                xyz   = "bad",
                prop1 = new ProgramWithTriggerAndCompoundBindingData.SubOject
                {
                    xyz = "abc"
                }
            };

            await host.GetJobHost().CallAsync <ProgramWithTriggerAndCompoundBindingData>("Func", new
            {
                triggers = new CloudQueueMessage(JsonConvert.SerializeObject(trigger))
            });

            // Now peek at messages.
            // queue name is normalized to lowercase.
            var queue = account.CreateCloudQueueClient().GetQueueReference("qname-abc");
            var msgs  = (await queue.GetMessagesAsync(10)).ToArray();

            Assert.Single(msgs);
            Assert.Equal("123", msgs[0].AsString);
        }
Esempio n. 3
0
        public void InvokeWithCompoundBindingData()
        {
            // Verify that queue binding pattern has uppercase letters in it. These get normalized to lowercase.
            Assert.NotEqual(ProgramWithTriggerAndBindingData.QueueOutName, ProgramWithTriggerAndBindingData.QueueOutName.ToLower());

            IStorageAccount account = CreateFakeStorageAccount();
            var             host    = TestHelpers.NewJobHost <ProgramWithTriggerAndCompoundBindingData>(account);

            var trigger = new ProgramWithTriggerAndCompoundBindingData.Poco
            {
                xyz   = "bad",
                prop1 = new ProgramWithTriggerAndCompoundBindingData.SubOject
                {
                    xyz = "abc"
                }
            };

            host.Call("Func", new
            {
                triggers = new CloudQueueMessage(JsonConvert.SerializeObject(trigger))
            });

            // Now peek at messages.
            // queue name is normalized to lowercase.
            var queue = account.CreateQueueClient().GetQueueReference("qname-abc");
            var msgs  = queue.GetMessages(10).ToArray();

            Assert.Equal(1, msgs.Length);
            Assert.Equal("123", msgs[0].AsString);
        }