Skip to content

Commit

Permalink
Add unit test for NpgmqClient constructor with connection string
Browse files Browse the repository at this point in the history
  • Loading branch information
brianpursley committed Dec 19, 2024
1 parent 8a77617 commit 66d6dad
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
16 changes: 16 additions & 0 deletions Npgmq.Test/NpgmqClientTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,22 @@ private async Task<bool> IsMinPgmqVersion(string minVersion)
return version is not null && new Version(version) >= new Version(minVersion);
}

[Fact]
public async Task NpgmqClient_should_work_when_created_using_a_connection_string()
{
// Arrange
await ResetTestQueueAsync();
var sut = new NpgmqClient(_connectionString); // Don't use _sut here, as we want to test a new instance

// Act
await sut.SendAsync(TestQueueName, new TestMessage { Foo = 123 });
var msg = await sut.ReadAsync<TestMessage>(TestQueueName);

// Assert
Assert.NotNull(msg);
msg.Message.ShouldDeepEqual(new TestMessage { Foo = 123 });
}

[Fact]
public async Task ArchiveAsync_should_archive_a_single_message()
{
Expand Down
4 changes: 2 additions & 2 deletions Npgmq/NpgmqClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public class NpgmqClient : INpgmqClient
private readonly NpgmqCommandFactory _commandFactory;

/// <summary>
/// Create a new <see cref="NpgmqClient"/>.
/// Create a new <see cref="NpgmqClient"/> using a connection string.
/// </summary>
/// <param name="connectionString">The connection string.</param>
public NpgmqClient(string connectionString)
Expand All @@ -25,7 +25,7 @@ public NpgmqClient(string connectionString)
}

/// <summary>
/// Create a new <see cref="NpgmqClient"/>.
/// Create a new <see cref="NpgmqClient"/> using an existing <see cref="NpgsqlConnection"/>.
/// </summary>
/// <param name="connection">The connection to use.</param>
public NpgmqClient(NpgsqlConnection connection)
Expand Down

0 comments on commit 66d6dad

Please sign in to comment.