예제 #1
0
        public void GivenEnrichedMessage_WhenAskingForItAsEventData_ThenItShouldReturnHydratedEventDataWithDeserializableBody()
        {
            // arrange
            const string      expected          = "{\"Dammit\":\"Bobby!\",\"Results\":[{}]}";
            ServiceBusMessage serviceBusMessage = new ServiceBusMessage(expected);

            // act
            EventData actual = serviceBusMessage.AsEventData();

            // assert
            actual.Body.Array?.Length.Should().BeGreaterThan(0);
            dynamic actualObject = JsonConvert.DeserializeObject <ExpandoObject>(Encoding.UTF8.GetString(actual.Body.Array));

            ((string)actualObject.Dammit).Should().Be("Bobby!");
            ((List <object>)actualObject.Results).Should().BeOfType <List <object> >();
            ((List <object>)actualObject.Results).First().Should().BeOfType <ExpandoObject>();
        }