public void GetBindingData_MultipleDispatch_ReturnsExpectedValue() { var messages = new ServiceBusReceivedMessage[3] { CreateMessageWithSystemProperties("Event 1"), CreateMessageWithSystemProperties("Event 2"), CreateMessageWithSystemProperties("Event 3"), }; var input = ServiceBusTriggerInput.CreateBatch(messages, null, null); var strategy = new ServiceBusTriggerBindingStrategy(); var bindingData = strategy.GetBindingData(input); Assert.AreEqual(BindingContractCount, bindingData.Count); Assert.AreSame(input.MessageActions, bindingData["MessageReceiver"]); Assert.AreSame(input.MessageActions, bindingData["MessageSession"]); Assert.AreSame(input.MessageActions, bindingData["MessageActions"]); Assert.AreSame(input.MessageActions, bindingData["SessionActions"]); // verify an array was created for each binding data type Assert.AreEqual(messages.Length, ((int[])bindingData["DeliveryCountArray"]).Length); Assert.AreEqual(messages.Length, ((string[])bindingData["DeadLetterSourceArray"]).Length); Assert.AreEqual(messages.Length, ((string[])bindingData["LockTokenArray"]).Length); Assert.AreEqual(messages.Length, ((DateTime[])bindingData["ExpiresAtUtcArray"]).Length); Assert.AreEqual(messages.Length, ((DateTime[])bindingData["EnqueuedTimeUtcArray"]).Length); Assert.AreEqual(messages.Length, ((string[])bindingData["MessageIdArray"]).Length); Assert.AreEqual(messages.Length, ((string[])bindingData["ContentTypeArray"]).Length); Assert.AreEqual(messages.Length, ((string[])bindingData["ReplyToArray"]).Length); Assert.AreEqual(messages.Length, ((long[])bindingData["SequenceNumberArray"]).Length); Assert.AreEqual(messages.Length, ((string[])bindingData["ToArray"]).Length); Assert.AreEqual(messages.Length, ((string[])bindingData["SubjectArray"]).Length); Assert.AreEqual(messages.Length, ((string[])bindingData["CorrelationIdArray"]).Length); Assert.AreEqual(messages.Length, ((IDictionary <string, object>[])bindingData["ApplicationPropertiesArray"]).Length); }
public void GetStaticBindingContract_ReturnsExpectedValue() { var strategy = new ServiceBusTriggerBindingStrategy(); var bindingDataContract = strategy.GetBindingContract(); CheckBindingContract(bindingDataContract); }
public void GetBindingContract_SingleDispatch_ReturnsExpectedValue() { var strategy = new ServiceBusTriggerBindingStrategy(); var bindingDataContract = strategy.GetBindingContract(true); CheckBindingContract(bindingDataContract); }
public void GetBindingData_SingleDispatch_ReturnsExpectedValue() { IDictionary <string, object> userProps = new Dictionary <string, object>(); userProps.Add(new KeyValuePair <string, object>("prop1", "value1")); userProps.Add(new KeyValuePair <string, object>("prop2", "value2")); var message = CreateMessageWithSystemProperties(applicationProperties: userProps); var input = ServiceBusTriggerInput.CreateSingle(message); var strategy = new ServiceBusTriggerBindingStrategy(); var bindingData = strategy.GetBindingData(input); Assert.AreEqual(15, bindingData.Count); Assert.AreSame(input.Receiver, bindingData["MessageReceiver"]); Assert.AreSame(input.SessionReceiver, bindingData["MessageSession"]); Assert.AreEqual(message.LockToken, bindingData["LockToken"]); Assert.AreEqual(message.SequenceNumber, bindingData["SequenceNumber"]); Assert.AreEqual(message.DeliveryCount, bindingData["DeliveryCount"]); Assert.AreSame(message.DeadLetterSource, bindingData["DeadLetterSource"]); Assert.AreEqual(message.ExpiresAt, bindingData["ExpiresAtUtc"]); Assert.AreEqual(message.EnqueuedTime, bindingData["EnqueuedTimeUtc"]); Assert.AreSame(message.MessageId, bindingData["MessageId"]); Assert.AreSame(message.ContentType, bindingData["ContentType"]); Assert.AreSame(message.ReplyTo, bindingData["ReplyTo"]); Assert.AreSame(message.To, bindingData["To"]); Assert.AreSame(message.Subject, bindingData["Label"]); Assert.AreSame(message.CorrelationId, bindingData["CorrelationId"]); IDictionary <string, object> bindingDataUserProps = bindingData["ApplicationProperties"] as IDictionary <string, object>; Assert.NotNull(bindingDataUserProps); Assert.AreEqual("value1", bindingDataUserProps["prop1"]); Assert.AreEqual("value2", bindingDataUserProps["prop2"]); }
public void GetBindingContract_MultipleDispatch_ReturnsExpectedValue() { var strategy = new ServiceBusTriggerBindingStrategy(); var bindingDataContract = strategy.GetBindingContract(false); Assert.AreEqual(BindingContractCount, bindingDataContract.Count); Assert.AreEqual(typeof(int[]), bindingDataContract["DeliveryCountArray"]); Assert.AreEqual(typeof(string[]), bindingDataContract["DeadLetterSourceArray"]); Assert.AreEqual(typeof(string[]), bindingDataContract["LockTokenArray"]); Assert.AreEqual(typeof(DateTime[]), bindingDataContract["ExpiresAtUtcArray"]); Assert.AreEqual(typeof(DateTime[]), bindingDataContract["EnqueuedTimeUtcArray"]); Assert.AreEqual(typeof(string[]), bindingDataContract["MessageIdArray"]); Assert.AreEqual(typeof(string[]), bindingDataContract["ContentTypeArray"]); Assert.AreEqual(typeof(string[]), bindingDataContract["ReplyToArray"]); Assert.AreEqual(typeof(long[]), bindingDataContract["SequenceNumberArray"]); Assert.AreEqual(typeof(string[]), bindingDataContract["ToArray"]); Assert.AreEqual(typeof(string[]), bindingDataContract["LabelArray"]); Assert.AreEqual(typeof(string[]), bindingDataContract["CorrelationIdArray"]); Assert.AreEqual(typeof(string[]), bindingDataContract["ReplyToSessionIdArray"]); Assert.AreEqual(typeof(string[]), bindingDataContract["SessionIdArray"]); Assert.AreEqual(typeof(IDictionary <string, object>[]), bindingDataContract["ApplicationPropertiesArray"]); Assert.AreEqual(typeof(ServiceBusMessageActions), bindingDataContract["MessageReceiver"]); Assert.AreEqual(typeof(ServiceBusSessionMessageActions), bindingDataContract["MessageSession"]); Assert.AreEqual(typeof(ServiceBusMessageActions), bindingDataContract["MessageActions"]); Assert.AreEqual(typeof(ServiceBusSessionMessageActions), bindingDataContract["SessionActions"]); }
public void BindSingle_Returns_Exptected_Message() { string data = "123"; var strategy = new ServiceBusTriggerBindingStrategy(); ServiceBusTriggerInput triggerInput = strategy.ConvertFromString(data); var contract = strategy.GetBindingData(triggerInput); ServiceBusReceivedMessage single = strategy.BindSingle(triggerInput, null); string body = single.Body.ToString(); Assert.AreEqual(data, body); Assert.Null(contract["MessageReceiver"]); Assert.Null(contract["MessageSession"]); }
public void GetBindingData_MultipleDispatch_ReturnsExpectedValue() { var messages = new Message[3] { new Message(Encoding.UTF8.GetBytes("Event 1")), new Message(Encoding.UTF8.GetBytes("Event 2")), new Message(Encoding.UTF8.GetBytes("Event 3")), }; foreach (var message in messages) { SystemPropertiesCollection sysProps = GetSystemProperties(); TestHelpers.SetField(message, "SystemProperties", sysProps); } var input = ServiceBusTriggerInput.CreateBatch(messages); var strategy = new ServiceBusTriggerBindingStrategy(); var bindingData = strategy.GetBindingData(input); Assert.Equal(15, bindingData.Count); Assert.Same(input.MessageReceiver as MessageReceiver, bindingData["MessageReceiver"]); Assert.Same(input.MessageReceiver as IMessageSession, bindingData["MessageSession"]); // verify an array was created for each binding data type Assert.Equal(messages.Length, ((int[])bindingData["DeliveryCountArray"]).Length); Assert.Equal(messages.Length, ((string[])bindingData["DeadLetterSourceArray"]).Length); Assert.Equal(messages.Length, ((string[])bindingData["LockTokenArray"]).Length); Assert.Equal(messages.Length, ((DateTime[])bindingData["ExpiresAtUtcArray"]).Length); Assert.Equal(messages.Length, ((DateTime[])bindingData["EnqueuedTimeUtcArray"]).Length); Assert.Equal(messages.Length, ((string[])bindingData["MessageIdArray"]).Length); Assert.Equal(messages.Length, ((string[])bindingData["ContentTypeArray"]).Length); Assert.Equal(messages.Length, ((string[])bindingData["ReplyToArray"]).Length); Assert.Equal(messages.Length, ((long[])bindingData["SequenceNumberArray"]).Length); Assert.Equal(messages.Length, ((string[])bindingData["ToArray"]).Length); Assert.Equal(messages.Length, ((string[])bindingData["LabelArray"]).Length); Assert.Equal(messages.Length, ((string[])bindingData["CorrelationIdArray"]).Length); Assert.Equal(messages.Length, ((IDictionary <string, object>[])bindingData["UserPropertiesArray"]).Length); }
public void GetBindingData_SingleDispatch_ReturnsExpectedValue() { var message = new Message(new byte[] { }); SystemPropertiesCollection sysProp = GetSystemProperties(); TestHelpers.SetField(message, "SystemProperties", sysProp); IDictionary <string, object> userProps = new Dictionary <string, object>(); userProps.Add(new KeyValuePair <string, object>("prop1", "value1")); userProps.Add(new KeyValuePair <string, object>("prop2", "value2")); TestHelpers.SetField(message, "UserProperties", userProps); var input = ServiceBusTriggerInput.CreateSingle(message); var strategy = new ServiceBusTriggerBindingStrategy(); var bindingData = strategy.GetBindingData(input); Assert.Equal(15, bindingData.Count); // SystemPropertiesCollection is sealed Assert.Same(input.MessageReceiver as MessageReceiver, bindingData["MessageReceiver"]); Assert.Same(input.MessageReceiver as IMessageSession, bindingData["MessageSession"]); Assert.Equal(message.SystemProperties.LockToken, bindingData["LockToken"]); Assert.Equal(message.SystemProperties.SequenceNumber, bindingData["SequenceNumber"]); Assert.Equal(message.SystemProperties.DeliveryCount, bindingData["DeliveryCount"]); Assert.Same(message.SystemProperties.DeadLetterSource, bindingData["DeadLetterSource"]); Assert.Equal(message.ExpiresAtUtc, bindingData["ExpiresAtUtc"]); Assert.Same(message.MessageId, bindingData["MessageId"]); Assert.Same(message.ContentType, bindingData["ContentType"]); Assert.Same(message.ReplyTo, bindingData["ReplyTo"]); Assert.Same(message.To, bindingData["To"]); Assert.Same(message.Label, bindingData["Label"]); Assert.Same(message.CorrelationId, bindingData["CorrelationId"]); IDictionary <string, object> bindingDataUserProps = bindingData["UserProperties"] as Dictionary <string, object>; Assert.NotNull(bindingDataUserProps); Assert.Equal("value1", bindingDataUserProps["prop1"]); Assert.Equal("value2", bindingDataUserProps["prop2"]); }