Skip to content

Commit

Permalink
Adding MessageProcessor tests
Browse files Browse the repository at this point in the history
  • Loading branch information
blankensteiner committed Jun 18, 2024
1 parent ed51103 commit c788463
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/)

## [Unreleased]

### Added

- The consumer's subscription type is now part of the `IConsumer` interface

### Fixed

- Fixed race condition in `Producer` between `Send(...)` and `DisposeAsync()` dispose causing an unintended `DivideByZeroException`.
Expand Down
43 changes: 43 additions & 0 deletions tests/DotPulsar.Tests/Internal/MessageProcessorTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

namespace DotPulsar.Tests.Internal;

using DotPulsar.Abstractions;
using DotPulsar.Exceptions;
using DotPulsar.Internal;

[Trait("Category", "Unit")]
public sealed class MessageProcessorTests
{
[Theory]
[InlineAutoData(SubscriptionType.Shared)]
[InlineAutoData(SubscriptionType.KeyShared)]
public void Constructor_GivenSharedSubscriptionTypeWithOrderedAcknowledgment_ShouldThrowProcessingException(
SubscriptionType subscriptionType,
[AutoFixture.Xunit2.Frozen] IConsumer<byte[]> consumer,
ProcessingOptions options)
{
//Arrange
consumer.SubscriptionType.Returns(subscriptionType);

//Act
var exception = Record.Exception(() => new MessageProcessor<byte[]>(consumer, ProcessMessage, options));

//Assert
exception.Should().BeOfType<ProcessingException>();
}

private static ValueTask ProcessMessage(IMessage<byte[]> _1, CancellationToken _2) => ValueTask.CompletedTask;
}

0 comments on commit c788463

Please sign in to comment.