Пример #1
0
        public async Task Given_Parameter_When_Instantiated_Should_HaveContent()
        {
            var contentType = "application/json";
            var data        = new FakeData()
            {
                FakeProperty = "hello world"
            };

            var ce = new TheOtherFakeEvent();

            ce.EventType          = "com.example.someevent";
            ce.CloudEventsVersion = "0.1";
            ce.Source             = (new Uri("http://localhost")).ToString();
            ce.EventId            = Guid.NewGuid().ToString();
            ce.ContentType        = contentType;
            ce.Data = data;

            var serialised = JsonConvert.SerializeObject(ce);

            var content = new StructuredCloudEventContent <FakeData>(ce);

            var result = await content.ReadAsStringAsync().ConfigureAwait(false);

            result.Should().Be(serialised);
        }
        public void Given_CloudEvent_Should_Return_StructuredCloudEventContent()
        {
            var contentType = "application/json";
            var data        = new FakeData()
            {
                FakeProperty = "hello world"
            };

            var ce = new TheOtherFakeEvent();

            ce.EventType          = "com.example.someevent";
            ce.CloudEventsVersion = "0.1";
            ce.Source             = (new Uri("http://localhost")).ToString();
            ce.EventId            = Guid.NewGuid().ToString();
            ce.ContentType        = contentType;
            ce.Data = data;

            var content = CloudEventContentFactory.Create(ce);

            content.Should().BeOfType <StructuredCloudEventContent <FakeData> >();
        }
Пример #3
0
        public void Given_Parameter_When_Instantiated_Should_HaveContentType()
        {
            var contentType = "application/json";
            var charset     = "utf-8";
            var data        = new FakeData()
            {
                FakeProperty = "hello world"
            };

            var ce = new TheOtherFakeEvent();

            ce.EventType          = "com.example.someevent";
            ce.CloudEventsVersion = "0.1";
            ce.Source             = (new Uri("http://localhost")).ToString();
            ce.EventId            = Guid.NewGuid().ToString();
            ce.ContentType        = contentType;
            ce.Data = data;

            var content = new StructuredCloudEventContent <FakeData>(ce);

            content.Headers.ContentType.MediaType.Should().Be(contentType);
            content.Headers.ContentType.CharSet.Should().Be(charset);
        }