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>(); }
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(); }
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); }