-
Notifications
You must be signed in to change notification settings - Fork 5
Expand messaging extension test coverage #41
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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
38 changes: 38 additions & 0 deletions
38
test/Savvyio.Extensions.SimpleQueueService.Tests/ClientConfigExtensionsTest.cs
This file contains hidden or 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,38 @@ | ||
| using Amazon.Runtime; | ||
| using Amazon.SimpleNotificationService; | ||
| using Amazon.SQS; | ||
| using Codebelt.Extensions.Xunit; | ||
| using Xunit; | ||
| using Xunit.Abstractions; | ||
|
|
||
| namespace Savvyio.Extensions.SimpleQueueService | ||
| { | ||
| public class ClientConfigExtensionsTest : Test | ||
| { | ||
| public ClientConfigExtensionsTest(ITestOutputHelper output) : base(output) { } | ||
|
|
||
| [Fact] | ||
| public void IsValid_ShouldEvaluateConfigurations() | ||
| { | ||
| ClientConfig[] invalid = null; | ||
| Assert.False(invalid.IsValid()); | ||
|
|
||
| var valid = new ClientConfig[] { new AmazonSQSConfig(), new AmazonSimpleNotificationServiceConfig() }; | ||
| Assert.True(valid.IsValid()); | ||
|
|
||
| var wrongLength = new ClientConfig[] { new AmazonSQSConfig() }; | ||
| Assert.False(wrongLength.IsValid()); | ||
| } | ||
|
|
||
| [Fact] | ||
| public void ShouldResolveSpecificConfigurations() | ||
| { | ||
| var sqs = new AmazonSQSConfig(); | ||
| var sns = new AmazonSimpleNotificationServiceConfig(); | ||
| ClientConfig[] configs = { sqs, sns }; | ||
|
|
||
| Assert.Same(sqs, configs.SimpleQueueService()); | ||
| Assert.Same(sns, configs.SimpleNotificationService()); | ||
| } | ||
| } | ||
| } |
33 changes: 33 additions & 0 deletions
33
test/Savvyio.Extensions.SimpleQueueService.Tests/EventDriven/StringExtensionsTest.cs
This file contains hidden or 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,33 @@ | ||
| using System; | ||
| using Codebelt.Extensions.Xunit; | ||
| using Xunit; | ||
| using Xunit.Abstractions; | ||
|
|
||
| namespace Savvyio.Extensions.SimpleQueueService.EventDriven | ||
| { | ||
| public class StringExtensionsTest : Test | ||
| { | ||
| public StringExtensionsTest(ITestOutputHelper output) : base(output) { } | ||
|
|
||
| [Fact] | ||
| public void ToSnsUri_ShouldBuildArnWithDefaults() | ||
| { | ||
| var uri = "sample-topic".ToSnsUri(); | ||
|
|
||
| Assert.Equal(new Uri("arn:aws:sns:eu-west-1:000000000000:sample-topic"), uri); | ||
| } | ||
|
|
||
| [Fact] | ||
| public void ToSnsUri_ShouldRespectCustomOptions() | ||
| { | ||
| var uri = "topic".ToSnsUri(o => | ||
| { | ||
| o.Partition = "aws"; | ||
| o.Region = "us-east-1"; | ||
| o.AccountId = "123456789012"; | ||
| }); | ||
|
|
||
| Assert.Equal(new Uri("arn:aws:sns:us-east-1:123456789012:topic"), uri); | ||
| } | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Don’t mock IMarshaller; use a JsonMarshaller. Also verify CreateChannelAsync once.
Repo guideline: “Never mock IMarshaller; use a new JsonMarshaller instance instead.” Replace the mock and add a verify for channel creation.
Apply this diff:
public async Task EnsureConnectivityAsync_IsThreadSafe_WhenCalledConcurrently() { - var marshaller = new Mock<IMarshaller>().Object; + var marshaller = new JsonMarshaller(); var options = new RabbitMqMessageOptions { AmqpUrl = new Uri("amqp://localhost:5672") }; @@ await Task.WhenAll( sut.CallEnsureConnectivityAsync(), sut.CallEnsureConnectivityAsync()); factoryMock.Verify(f => f.CreateConnectionAsync(It.IsAny<CancellationToken>()), Times.Once); + connectionMock.Verify(c => c.CreateChannelAsync(It.IsAny<CreateChannelOptions?>(), It.IsAny<CancellationToken>()), Times.Once); }Add the appropriate using for JsonMarshaller (adjust namespace to your concrete type if different):
🤖 Prompt for AI Agents