Esempio n. 1
0
        public void GivenInvalidBody_WhenUsingAskingForServiceBusMessage_ThenItShouldShouldReturnNullServiceBusMessage()
        {
            // arrange
            const string expected = "{'businessName':'Strickland Propane, LLC'}";

            Environment.SetEnvironmentVariable("ServiceBusConnectionString", "Endpoint=sb://googazon-rivers.servicebus.windows.net/;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=dammitbobby");
            EventMessageBody eventMessageBody = new EventMessageBody(new EventData(Encoding.UTF8.GetBytes(expected)));

            // act
            ServiceBusMessage actual = eventMessageBody.AsServiceBusMessage();

            // assert
            actual.Should().BeOfType <NullServiceBusMessage>();
        }
Esempio 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();
        }
Esempio 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);
        }