From 66d6dad9998f55ac32dc2d98937d3d9adb001a6c Mon Sep 17 00:00:00 2001 From: Brian Pursley Date: Thu, 19 Dec 2024 12:38:57 -0500 Subject: [PATCH] Add unit test for NpgmqClient constructor with connection string --- Npgmq.Test/NpgmqClientTest.cs | 16 ++++++++++++++++ Npgmq/NpgmqClient.cs | 4 ++-- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/Npgmq.Test/NpgmqClientTest.cs b/Npgmq.Test/NpgmqClientTest.cs index d20e482..5cc4ecb 100644 --- a/Npgmq.Test/NpgmqClientTest.cs +++ b/Npgmq.Test/NpgmqClientTest.cs @@ -56,6 +56,22 @@ private async Task 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(TestQueueName); + + // Assert + Assert.NotNull(msg); + msg.Message.ShouldDeepEqual(new TestMessage { Foo = 123 }); + } + [Fact] public async Task ArchiveAsync_should_archive_a_single_message() { diff --git a/Npgmq/NpgmqClient.cs b/Npgmq/NpgmqClient.cs index 210501f..4163b27 100644 --- a/Npgmq/NpgmqClient.cs +++ b/Npgmq/NpgmqClient.cs @@ -16,7 +16,7 @@ public class NpgmqClient : INpgmqClient private readonly NpgmqCommandFactory _commandFactory; /// - /// Create a new . + /// Create a new using a connection string. /// /// The connection string. public NpgmqClient(string connectionString) @@ -25,7 +25,7 @@ public NpgmqClient(string connectionString) } /// - /// Create a new . + /// Create a new using an existing . /// /// The connection to use. public NpgmqClient(NpgsqlConnection connection)