Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mikeminutillo committed Nov 7, 2023
1 parent 79dfabe commit c36da4f
Showing 1 changed file with 6 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,10 @@ static IEnumerable<TestCaseData> GenerateTestCases(bool passMessageIdInMessageAt
native => native
.WithMessageAttributeHeader(TransportHeaders.S3BodyKey, "Will be overwritten", condition: pushBodyToS3)
.WithMessageAttributeHeader("SomeKey", "SomeValue")
.WithMessageAttributeHeader(Headers.MessageId, "Will be overwritten", condition: passMessageIdInNsbHeaders)
.WithMessageAttributeHeader(Headers.MessageId, nsbMessageIdPassedThroughHeaders, condition: passMessageIdInNsbHeaders)
.WithMessageAttribute(TransportHeaders.S3BodyKey, "S3 Body Key", condition: pushBodyToS3)
.WithBody("Body Contents", condition: passBodyInMessage),
transport => transport
// HINT: Message Id from headers is going to get overwritten no matter what
.WithHeader(Headers.MessageId, nativeMessageId)
.WithHeader(Headers.MessageId, nsbMessageIdPassedThroughMessageAttribute, condition: passMessageIdInMessageAttribute)
.WithHeader("SomeKey", "SomeValue")
.WithBody("Body Contents", condition: passBodyInMessage)
.WithHeader(TransportHeaders.S3BodyKey, "S3 Body Key", condition: pushBodyToS3)
Expand Down Expand Up @@ -88,7 +85,9 @@ static IEnumerable<TestCaseData> GenerateTestCases(bool passMessageIdInMessageAt
.WithHeader(TransportHeaders.S3BodyKey, "S3 body key", condition: pushBodyToS3)
.WithS3BodyKey("S3 body key", condition: pushBodyToS3),
// HINT: There is no way to pass this via headers. It should fall back to native message id
expectedMessageId: passMessageIdInNsbHeaders && !passMessageIdInMessageAttribute ? nativeMessageId : null
expectedMessageId: passMessageIdInMessageAttribute
? nsbMessageIdPassedThroughMessageAttribute
: nativeMessageId
);
#endregion

Expand Down Expand Up @@ -160,15 +159,15 @@ TestCaseData TestCase(
var transportMessageBuilder = new TransportMessageBuilder()
// HINT: Last in wins
.WithHeader(Headers.MessageId, nativeMessageId)
.WithHeader(Headers.MessageId, nsbMessageIdPassedThroughHeaders, condition: passMessageIdInNsbHeaders)
.WithHeader(Headers.MessageId, nsbMessageIdPassedThroughMessageAttribute, condition: passMessageIdInMessageAttribute)
.WithHeader(Headers.MessageId, nsbMessageIdPassedThroughHeaders, condition: passMessageIdInNsbHeaders)
.WithHeader(Headers.MessageId, expectedMessageId, condition: expectedMessageId != null);

transport?.Invoke(transportMessageBuilder);

var testCaseName = name;
testCaseName += passMessageIdInMessageAttribute ? " - Message Id in message attribute" : " - Message Id NOT in message attribute";
testCaseName += passMessageIdInNsbHeaders ? " - NSB message Id provided" : " - NSB message Id NOT provided";
testCaseName += passMessageIdInNsbHeaders ? " - Message Id in NSB headers" : " - Message Id NOT in NSB headers";
testCaseName += pushBodyToS3 ? " - body in S3" : " - body on message";

return new TestCaseData(
Expand Down

0 comments on commit c36da4f

Please sign in to comment.