public void when_writing_entity_adds_payload_to_dictionary() { var entity = new CloudEventEntry(EventEntryTestHelper.Create(payloadNames: new string[] { "message1", "message2" }, payload: new object[] { "value1", "value2" })); entity.CreateKey(true, 0); var dict = entity.CreateTableEntity().WriteEntity(null); Assert.IsTrue(dict.ContainsKey("Payload_message1")); Assert.IsTrue(dict.ContainsKey("Payload_message2")); }
public void when_having_big_message_value_then_truncates() { var entity = new CloudEventEntry(); entity.CreateKey(true, 0); entity.Message = new string('a', 500000); var dict = entity.CreateTableEntity().WriteEntity(null); Assert.AreEqual(new string('a', 30000) + "--TRUNCATED--", dict["Message"].StringValue); }
public void when_having_big_payload_then_truncates() { var entity = new CloudEventEntry(EventEntryTestHelper.Create(payloadNames: new string[] { "arg1" }, payload: new object[] { new string('a', 500000) })); entity.CreateKey(true, 0); var dict = entity.CreateTableEntity().WriteEntity(null); StringAssert.Contains(dict["Payload"].StringValue, "'payload_serialization_error'"); Assert.IsFalse(dict.ContainsKey("Payload_arg1")); }
public void when_having_big_overall_payloads_then_stores_warning_and_does_not_contain_payload() { var entity = new CloudEventEntry(EventEntryTestHelper.Create(payloadNames: Enumerable.Range(0, 50).Select(i => "arg" + i), payload: Enumerable.Range(0, 50).Select(i => new string('a', 2000)))); entity.CreateKey(true, 0); var dict = entity.CreateTableEntity().WriteEntity(null); StringAssert.Contains(dict["Payload"].StringValue, "'payload_serialization_error'"); Assert.AreEqual(0, dict.Keys.Count(x => x.StartsWith("Payload_"))); }
public void when_having_big_payload_then_truncates() { var entity = new CloudEventEntry(); entity.CreateKey(true, 0); entity.Payload.Add("arg1", new string('a', 500000)); var dict = entity.CreateTableEntity().WriteEntity(null); StringAssert.Contains(dict["Payload"].StringValue, "'payload_serialization_error'"); Assert.IsFalse(dict.ContainsKey("Payload_arg1")); }
public void when_writing_entity_adds_payload_to_dictionary() { var entity = new CloudEventEntry(); entity.CreateKey(true, 0); entity.Payload.Add("message1", "value1"); entity.Payload.Add("message2", "value2"); var dict = entity.CreateTableEntity().WriteEntity(null); Assert.IsTrue(dict.ContainsKey("Payload_message1")); Assert.IsTrue(dict.ContainsKey("Payload_message2")); }
public void when_having_big_overall_payloads_then_stores_warning_and_does_not_contain_payload() { var entity = new CloudEventEntry(); entity.CreateKey(true, 0); for (int i = 0; i < 50; i++) { entity.Payload.Add("arg" + i, new string('a', 2000)); } var dict = entity.CreateTableEntity().WriteEntity(null); StringAssert.Contains(dict["Payload"].StringValue, "'payload_serialization_error'"); Assert.AreEqual(0, dict.Keys.Count(x => x.StartsWith("Payload_"))); }
public void when_writing_entity_keeps_proper_type() { var guid = Guid.NewGuid(); var binary = new byte[] { 1, 2, 3, 4 }; var entity = new CloudEventEntry(EventEntryTestHelper.Create( payloadNames: new string[] { "string1", "int1", "long1", "double1", "bool1", "bool2", "guid1", "binary1" }, payload: new object[] { "This is a string", 123456, 123456L, 123456D, true, false, guid, binary })); entity.CreateKey(true, 0); var dict = entity.CreateTableEntity().WriteEntity(null); Assert.AreEqual <string>("This is a string", dict["Payload_string1"].StringValue); Assert.AreEqual <int>(123456, dict["Payload_int1"].Int32Value.Value); Assert.AreEqual <long>(123456L, dict["Payload_long1"].Int64Value.Value); Assert.AreEqual <double>(123456D, dict["Payload_double1"].DoubleValue.Value); Assert.AreEqual <Guid>(guid, dict["Payload_guid1"].GuidValue.Value); Assert.AreEqual <bool>(true, dict["Payload_bool1"].BooleanValue.Value); Assert.AreEqual <bool>(false, dict["Payload_bool2"].BooleanValue.Value); Assert.AreEqual <byte[]>(binary, dict["Payload_binary1"].BinaryValue); }