Minor cleanup and updated the changelog
diff --git a/CHANGELOG.md b/CHANGELOG.md
index eada720..54f3e9f 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -4,6 +4,12 @@
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
+## [Unreleased]
+
+### Changed
+
+- The KeyBytes property on MessageMetadata returned null if the key was set via a string. Now it will return string keys as UTF8 bytes.
+
## [1.0.2] - 2021-04-30
### Fixed
diff --git a/tests/DotPulsar.Tests/Internal/PartitionedProducerProcessTests.cs b/tests/DotPulsar.Tests/Internal/PartitionedProducerProcessTests.cs
index 255b87a..476a81a 100644
--- a/tests/DotPulsar.Tests/Internal/PartitionedProducerProcessTests.cs
+++ b/tests/DotPulsar.Tests/Internal/PartitionedProducerProcessTests.cs
@@ -49,8 +49,7 @@
processManager.Add(process);
}
- var partitionedStateManager =
- new StateManager<ProducerState>(ProducerState.Disconnected, ProducerState.Closed, ProducerState.Faulted);
+ var partitionedStateManager = new StateManager<ProducerState>(ProducerState.Disconnected, ProducerState.Closed, ProducerState.Faulted);
var producerProcess = new ProducerProcess(partitionedProducerGuid, partitionedStateManager, establishNewChannel, new ProcessManager(connectionPool));
processManager.Add(producerProcess);
diff --git a/tests/DotPulsar.Tests/MessageIdTests.cs b/tests/DotPulsar.Tests/MessageIdTests.cs
index 1b87744..10268e4 100644
--- a/tests/DotPulsar.Tests/MessageIdTests.cs
+++ b/tests/DotPulsar.Tests/MessageIdTests.cs
@@ -139,7 +139,7 @@
MessageId m2 = null;
(m1 == m2).Should().BeTrue();
- (m1 == null).Should().BeTrue();
+ (m1 is null).Should().BeTrue();
(m1 != m2).Should().BeFalse();
}
@@ -149,7 +149,7 @@
var m1 = new MessageId(1, 2, 3, 4);
MessageId m2 = null;
- (m1 == null).Should().BeFalse();
+ (m1 is null).Should().BeFalse();
(m1 == m2).Should().BeFalse();
m1.Equals(m2).Should().BeFalse();
(m1 != m2).Should().BeTrue();
diff --git a/tests/DotPulsar.Tests/PulsarClientTests.cs b/tests/DotPulsar.Tests/PulsarClientTests.cs
index 67370d8..f459a41 100644
--- a/tests/DotPulsar.Tests/PulsarClientTests.cs
+++ b/tests/DotPulsar.Tests/PulsarClientTests.cs
@@ -19,6 +19,7 @@
using DotPulsar.Internal.Abstractions;
using DotPulsar.Internal.PulsarApi;
using Extensions;
+ using FluentAssertions;
using NSubstitute;
using System;
using System.Threading;
@@ -29,47 +30,40 @@
public class PulsarClientTests
{
[Fact]
- public async Task GetPartitionedProducer_GivenPartitionedTopic_ShouldReturnPartitionProducer()
+ public async Task NewProducer_GivenPartitionedTopic_ShouldReturnPartitionProducer()
{
//Arrange
- var topicName = "persistent://public/default/test-topic";
- uint expectedPartitions = 3;
+ const string topicName = "persistent://public/default/test-topic";
+ const uint expectedPartitions = 3;
+
+ CommandPartitionedTopicMetadata? saveGetPartitions = null; // use saveGetPartitions to assert CommandPartitionedTopicMetadata.
var connection = Substitute.For<IConnection>();
-
- // use saveGetPartitions to assert CommandPartitionedTopicMetadata.
- CommandPartitionedTopicMetadata? saveGetPartitions = null;
-
connection.Send(Arg.Any<CommandPartitionedTopicMetadata>(), Arg.Any<CancellationToken>())
- .Returns(new BaseCommand()
+ .Returns(new BaseCommand
{
CommandType = BaseCommand.Type.PartitionedMetadataResponse,
- PartitionMetadataResponse = new CommandPartitionedTopicMetadataResponse()
+ PartitionMetadataResponse = new CommandPartitionedTopicMetadataResponse
{
- Response = CommandPartitionedTopicMetadataResponse.LookupType.Success, Partitions = expectedPartitions
+ Response = CommandPartitionedTopicMetadataResponse.LookupType.Success,
+ Partitions = expectedPartitions
}
})
- .AndDoes(info =>
- {
- saveGetPartitions = (CommandPartitionedTopicMetadata) info[0];
- });
+ .AndDoes(info => saveGetPartitions = (CommandPartitionedTopicMetadata) info[0]);
var connectionPool = Substitute.For<IConnectionPool>();
+ connectionPool.FindConnectionForTopic(Arg.Any<string>(), Arg.Any<CancellationToken>()).Returns(connection);
- connectionPool.FindConnectionForTopic(Arg.Any<string>(), Arg.Any<CancellationToken>())
- .Returns(connection);
-
- var client = PulsarClientFactory.CreatePulsarClient(connectionPool, new ProcessManager(connectionPool), Substitute.For<IHandleException>(), new Uri
- ("pusarl://localhost:6650/"));
+ var client = PulsarClientFactory.CreatePulsarClient(connectionPool, new ProcessManager(connectionPool), Substitute.For<IHandleException>(), new Uri("pusarl://localhost:6650/"));
//Act
await using var producer = client.NewProducer(Schema.String).Topic(topicName).Create();
await ((IEstablishNewChannel) producer).EstablishNewChannel(new CancellationTokenSource(TimeSpan.FromSeconds(10)).Token);
//Assert
- Assert.NotNull(saveGetPartitions);
- Assert.Equal(saveGetPartitions?.Topic, topicName);
- Assert.IsType<Producer<string>>(producer);
+ saveGetPartitions.Should().NotBeNull();
+ saveGetPartitions!.Topic.Should().Be(topicName);
+ producer.Should().BeOfType<Producer<string>>();
}
}
}