Exemplo n.º 1
0
        public void GivenEnrichedMessage_WhenAskingIsEnriched_ThenItShouldReturnTrue()
        {
            // arrange
            const string      expected          = "{\"Dammit\":\"Bobby!\",\"Results\":[{}]}";
            ServiceBusMessage serviceBusMessage = new ServiceBusMessage(expected);

            // act
            bool actual = serviceBusMessage.IsEnriched();

            // assert
            actual.Should().BeTrue();
        }
Exemplo n.º 2
0
        public void GivenUnenrichedMessage_WhenAskingForEnrichedInstance_ThenItShouldReturnNewObjectWithEnrichment()
        {
            // arrange
            const string      json = "{\"Dammit\":\"Bobby!\"}";
            ServiceBusMessage serviceBusMessage = new ServiceBusMessage(json);
            dynamic           enrichment        = new ExpandoObject();

            // act
            ServiceBusMessage actual = serviceBusMessage.EnrichedInstance(enrichment);

            // assert
            actual.Should().NotBe(serviceBusMessage);
            actual.IsEnriched().Should().BeTrue();
        }
Exemplo n.º 3
0
        public void GivenEnrichedMessage_WhenAskingForEnrichedInstance_ThenItShouldReturnNewObjectWithOriginalAndNewEnrichment()
        {
            // arrange
            const string      json              = "{\"Dammit\":\"Bobby!\",\"Results\":[{\"Mother\":\"Will not be happy.\"}]}";
            const string      expected          = "{\"Dammit\":\"Bobby!\",\"Results\":[{\"Mother\":\"Will not be happy.\"},{\"Hello\":\", World.\"}]}";
            ServiceBusMessage serviceBusMessage = new ServiceBusMessage(json);
            Enrichment        enrichment        = new Enrichment();

            // act
            ServiceBusMessage actual = serviceBusMessage.EnrichedInstance(enrichment);

            // assert
            actual.Should().NotBe(serviceBusMessage);
            actual.IsEnriched().Should().BeTrue();
            ((string)actual).Should().Be(expected);
        }
        public static async Task Run(
            [ServiceBusTrigger("customerservice", "brickandmortar", Connection = "ServiceBusConnectionString")] string message,
            [EventHub("rapids", Connection = "EventHubConnectionString")] IAsyncCollector <EventData> collector)
        {
            try
            {
                ServiceBusMessage serviceBusMessage = new ServiceBusMessage(message);
                if (serviceBusMessage.IsEnriched())
                {
                    return;
                }

                await collector.AddAsync(serviceBusMessage.EnrichedInstance(new BrickAndMortarState()).AsEventData());
            }
            catch (Exception e)
            {
                Console.WriteLine($"{e.Message}\n\n{e.StackTrace}");
            }
        }