-
Notifications
You must be signed in to change notification settings - Fork 122
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: access message timestamp from message consumer context
- Loading branch information
1 parent
2faab89
commit c0e5bff
Showing
3 changed files
with
47 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
namespace KafkaFlow.UnitTests | ||
{ | ||
using System; | ||
using System.Threading; | ||
using Confluent.Kafka; | ||
using FluentAssertions; | ||
using KafkaFlow.Consumers; | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
|
||
[TestClass] | ||
public class MessageContextConsumerTests | ||
{ | ||
[TestMethod] | ||
public void MessageTimestamp_ConsumeResultHasMessageTimestamp_ReturnsMessageTimestampFromResult() | ||
{ | ||
// Arrange | ||
var expectedMessageTimestamp = new DateTime(2020, 1, 1, 0, 0, 0); | ||
|
||
var consumerResult = new ConsumeResult<byte[], byte[]> | ||
{ | ||
Message = new Message<byte[], byte[]> | ||
{ | ||
Timestamp = new Timestamp(expectedMessageTimestamp) | ||
} | ||
}; | ||
|
||
var target = new MessageContextConsumer(null, "consumer", null, consumerResult, CancellationToken.None); | ||
|
||
// Act | ||
var messageTimestamp = target.MessageTimestamp; | ||
|
||
// Assert | ||
messageTimestamp.Should().Be(expectedMessageTimestamp); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters