public void EncodeStructured()
        {
            var cloudEvent    = CreateSampleEvent();
            var expectedBytes = TestResourceHelper.LoadBytes("structured-mode-body.json");

            var converter   = new ProtobufJsonCloudEventFormatter <StorageObjectData>();
            var actualBytes = converter.EncodeStructuredModeMessage(cloudEvent, out var contentType).ToArray();

            Assert.Equal("application/cloudevents+json", contentType.MediaType);

            AssertJsonBytesEqual(expectedBytes, actualBytes);
        }
        public void EncodeStructured_NoData()
        {
            var cloudEvent = CreateSampleEvent();

            cloudEvent.Data = null;

            var converter = new ProtobufJsonCloudEventFormatter <StorageObjectData>();
            var bytes     = converter.EncodeStructuredModeMessage(cloudEvent, out var contentType).ToArray();

            Assert.Equal("application/cloudevents+json", contentType.MediaType);

            var obj = JObject.Parse(Encoding.UTF8.GetString(bytes));

            Assert.False(obj.ContainsKey("data"));
        }