This is an automated email from the ASF dual-hosted git repository. blankensteiner pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/pulsar-dotpulsar.git
The following commit(s) were added to refs/heads/master by this push: new 1622e28 Minor cleanup and updated the changelog 1622e28 is described below commit 1622e28ddc869aa150d7a9af631e0bd83737265d Author: Daniel Blankensteiner <d...@vmail.dk> AuthorDate: Mon Jun 21 22:35:08 2021 +0200 Minor cleanup and updated the changelog --- CHANGELOG.md | 6 ++++ .../Internal/PartitionedProducerProcessTests.cs | 3 +- tests/DotPulsar.Tests/MessageIdTests.cs | 4 +-- tests/DotPulsar.Tests/PulsarClientTests.cs | 38 +++++++++------------- 4 files changed, 25 insertions(+), 26 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index eada720..54f3e9f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file. 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 @@ namespace DotPulsar.Tests.Internal 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 @@ namespace DotPulsar.Tests MessageId m2 = null; (m1 == m2).Should().BeTrue(); - (m1 == null).Should().BeTrue(); + (m1 is null).Should().BeTrue(); (m1 != m2).Should().BeFalse(); } @@ -149,7 +149,7 @@ namespace DotPulsar.Tests 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 @@ namespace DotPulsar.Tests using DotPulsar.Internal.Abstractions; using DotPulsar.Internal.PulsarApi; using Extensions; + using FluentAssertions; using NSubstitute; using System; using System.Threading; @@ -29,47 +30,40 @@ namespace DotPulsar.Tests 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; - var connection = Substitute.For<IConnection>(); - - // use saveGetPartitions to assert CommandPartitionedTopicMetadata. - CommandPartitionedTopicMetadata? saveGetPartitions = null; + CommandPartitionedTopicMetadata? saveGetPartitions = null; // use saveGetPartitions to assert CommandPartitionedTopicMetadata. + var connection = Substitute.For<IConnection>(); 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>>(); } } }