public void PopulateCloudEvent_DefaultToJson()
        {
            var data = new StorageObjectData {
                Bucket = "my-bucket"
            };
            var evt       = new CloudEvent("type", new Uri("//source"));
            var converter = new ProtobufCloudEventDataConverter <StorageObjectData>();

            converter.PopulateCloudEvent(evt, data);
            Assert.Equal("{ \"bucket\": \"my-bucket\" }", evt.Data);
            Assert.Equal(JsonContentType, evt.DataContentType);
        }
        public void PopulateCloudEvent_UnknownDataContentType()
        {
            var data = new StorageObjectData {
                Bucket = "my-bucket"
            };
            var evt = new CloudEvent("type", new Uri("//source"))
            {
                DataContentType = new ContentType("application/unknown")
            };
            var converter = new ProtobufCloudEventDataConverter <StorageObjectData>();

            Assert.Throws <ArgumentException>(() => converter.PopulateCloudEvent(evt, data));
        }
        public void PopulateCloudEvent_ExplicitlyBinary()
        {
            var data = new StorageObjectData {
                Bucket = "my-bucket"
            };
            var evt = new CloudEvent("type", new Uri("//source"))
            {
                DataContentType = ProtobufContentType
            };
            var converter = new ProtobufCloudEventDataConverter <StorageObjectData>();

            converter.PopulateCloudEvent(evt, data);
            Assert.Equal(data.ToByteArray(), evt.Data);
            Assert.Equal(ProtobufContentType, evt.DataContentType);
        }