diff --git a/README.md b/README.md index b5a3f45..a4679db 100644 --- a/README.md +++ b/README.md @@ -4,28 +4,30 @@ A C# wrapper for a RabbitMQ client. ## Status -| | | -|----------------------:|-----------------------| -| Build & Test Status (main) | [![Build&Test](https://github.com/jjm-one/jjm.one.RabbitMqClientWrapper/actions/workflows/dotnet.yml/badge.svg)](https://github.com/jjm-one/jjm.one.RabbitMqClientWrapper/actions/workflows/dotnet.yml) | -| Nuget Package Version | [![Nuget Version](https://img.shields.io/nuget/v/jjm.one.RabbitMqClientWrapper?style=flat-square)](https://www.nuget.org/packages/jjm.one.RabbitMqClientWrapper/) | +| | | +|------------------------------:|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| Build & Test Status (main) | [![Build&Test](https://github.com/jjm-one/jjm.one.RabbitMqClientWrapper/actions/workflows/dotnet.yml/badge.svg)](https://github.com/jjm-one/jjm.one.RabbitMqClientWrapper/actions/workflows/dotnet.yml) | +| Nuget Package Version | [![Nuget Version](https://img.shields.io/nuget/v/jjm.one.RabbitMqClientWrapper?style=flat-square)](https://www.nuget.org/packages/jjm.one.RabbitMqClientWrapper/) | | SonarCloudQuality Gate Status | [![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=jjm-one_jjm.one.RabbitMqClientWrapper&metric=alert_status)](https://sonarcloud.io/summary/new_code?id=jjm-one_jjm.one.RabbitMqClientWrapper) | ## Table of contents - [jjm.one.RabbitMqClientWrapper](#jjmonerabbitmqclientwrapper) - - [Status](#status) - - [Table of contents](#table-of-contents) - - [Nuget Package](#nuget-package) - - [Full Documentation](#full-documentation) - - [Repo](#repo) + - [Status](#status) + - [Table of contents](#table-of-contents) + - [Nuget Package](#nuget-package) + - [Full Documentation](#full-documentation) + - [Repo](#repo) ## Nuget Package -You can get the latest version of this software as a nuget package form [nuget.org](https://www.nuget.org/packages/jjm.one.RabbitMqClientWrapper/) +You can get the latest version of this software as a nuget package +form [nuget.org](https://www.nuget.org/packages/jjm.one.RabbitMqClientWrapper/) ## Full Documentation -The full documentation for this package can be found [here](https://jjm-one.github.io/jjm.one.RabbitMqClientWrapper/main/doc/html/index.html). +The full documentation for this package can be +found [here](https://jjm-one.github.io/jjm.one.RabbitMqClientWrapper/main/doc/html/index.html). ## Repo diff --git a/src/jjm.one.RabbitMqClientWrapper.Tests/Usings.cs b/src/jjm.one.RabbitMqClientWrapper.Tests/Usings.cs index 8c927eb..7fef4b0 100644 --- a/src/jjm.one.RabbitMqClientWrapper.Tests/Usings.cs +++ b/src/jjm.one.RabbitMqClientWrapper.Tests/Usings.cs @@ -1 +1,2 @@ -global using Xunit; \ No newline at end of file +global using Xunit; +global using FluentAssertions; \ No newline at end of file diff --git a/src/jjm.one.RabbitMqClientWrapper.Tests/di/RmqcWrapperDiTests.cs b/src/jjm.one.RabbitMqClientWrapper.Tests/di/RmqcWrapperDiTests.cs index 7890d05..23a8f02 100644 --- a/src/jjm.one.RabbitMqClientWrapper.Tests/di/RmqcWrapperDiTests.cs +++ b/src/jjm.one.RabbitMqClientWrapper.Tests/di/RmqcWrapperDiTests.cs @@ -1,4 +1,3 @@ -using FluentAssertions; using jjm.one.RabbitMqClientWrapper.di; using jjm.one.RabbitMqClientWrapper.main; using jjm.one.RabbitMqClientWrapper.types; @@ -8,7 +7,7 @@ namespace jjm.one.RabbitMqClientWrapper.Tests.di; /// -/// This class contains the unit tests for the class. +/// This class contains the unit tests for the class. /// public class RmqcWrapperDiTests { @@ -17,11 +16,11 @@ public class RmqcWrapperDiTests private readonly IHostBuilder _hostBuilder; #endregion - + #region ctor /// - /// The default constructor of the class. + /// The default constructor of the class. /// public RmqcWrapperDiTests() { @@ -29,11 +28,11 @@ public RmqcWrapperDiTests() } #endregion - + #region tests /// - /// Tests the static AddRmqcCore function. + /// Tests the static AddRmqcCore function. /// [Fact] public void RmqcWrapperDiTest_AddRmqcWrapperTest() diff --git a/src/jjm.one.RabbitMqClientWrapper.Tests/di/core/RmqcCoreDiTests.cs b/src/jjm.one.RabbitMqClientWrapper.Tests/di/core/RmqcCoreDiTests.cs index 86ab2a4..0752cc4 100644 --- a/src/jjm.one.RabbitMqClientWrapper.Tests/di/core/RmqcCoreDiTests.cs +++ b/src/jjm.one.RabbitMqClientWrapper.Tests/di/core/RmqcCoreDiTests.cs @@ -1,4 +1,3 @@ -using FluentAssertions; using jjm.one.RabbitMqClientWrapper.di.core; using jjm.one.RabbitMqClientWrapper.main.core; using jjm.one.RabbitMqClientWrapper.types; @@ -8,7 +7,7 @@ namespace jjm.one.RabbitMqClientWrapper.Tests.di.core; /// -/// This class contains the unit tests for the class. +/// This class contains the unit tests for the class. /// public class RmqcCoreDiTests { @@ -17,11 +16,11 @@ public class RmqcCoreDiTests private readonly IHostBuilder _hostBuilder; #endregion - + #region ctor /// - /// The default constructor of the class. + /// The default constructor of the class. /// public RmqcCoreDiTests() { @@ -29,11 +28,11 @@ public RmqcCoreDiTests() } #endregion - + #region tests /// - /// Tests the static AddRmqcCore function. + /// Tests the static AddRmqcCore function. /// [Fact] public void RmqcCoreDiTest_AddRmqcCoreTest() diff --git a/src/jjm.one.RabbitMqClientWrapper.Tests/jjm.one.RabbitMqClientWrapper.Tests.csproj b/src/jjm.one.RabbitMqClientWrapper.Tests/jjm.one.RabbitMqClientWrapper.Tests.csproj index 02d3924..ddfd617 100644 --- a/src/jjm.one.RabbitMqClientWrapper.Tests/jjm.one.RabbitMqClientWrapper.Tests.csproj +++ b/src/jjm.one.RabbitMqClientWrapper.Tests/jjm.one.RabbitMqClientWrapper.Tests.csproj @@ -1,56 +1,50 @@ - - net8.0 - disable - enable - 1.0.0-alpha.7 - Jonas Merkle [JJM] - © by Jonas Merkle [JJM], 2024. - jjm.one.RabbitMqClientWrapper.Tests - jjm.one.RabbitMqClientWrapper.Tests - A csharp wrapper for a RabbitMQ client. (Unit-Tests) - utility, helper, wrapper, rabbitmq, client, csharp - https://github.com/jjm-one/jjm.one.RabbitMqClientWrapper - git - https://github.com/jjm-one/jjm.one.RabbitMqClientWrapper.git - True - jjm.one.RabbitMqClientWrapper.Tests.SignKey.snk - false - true - + + net8.0 + disable + enable + 1.0.0-alpha.7 + Jonas Merkle [JJM] + © by Jonas Merkle [JJM], 2024. + jjm.one.RabbitMqClientWrapper.Tests + jjm.one.RabbitMqClientWrapper.Tests + A csharp wrapper for a RabbitMQ client. (Unit-Tests) + utility, helper, wrapper, rabbitmq, client, csharp + https://github.com/jjm-one/jjm.one.RabbitMqClientWrapper + git + https://github.com/jjm-one/jjm.one.RabbitMqClientWrapper.git + True + jjm.one.RabbitMqClientWrapper.Tests.SignKey.snk + false + true + - - latestmajor - - - - latestmajor - - + + latestmajor + + + latestmajor + - - - - - - - runtime; build; native; contentfiles; analyzers; buildtransitive - all - - - runtime; build; native; contentfiles; analyzers; buildtransitive - all - - - - + + + + + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + + - - - - - - - + + + diff --git a/src/jjm.one.RabbitMqClientWrapper.Tests/main/RmqcWrapperTests.cs b/src/jjm.one.RabbitMqClientWrapper.Tests/main/RmqcWrapperTests.cs index 3d72b69..576fe28 100644 --- a/src/jjm.one.RabbitMqClientWrapper.Tests/main/RmqcWrapperTests.cs +++ b/src/jjm.one.RabbitMqClientWrapper.Tests/main/RmqcWrapperTests.cs @@ -1,5 +1,4 @@ using System; -using FluentAssertions; using jjm.one.RabbitMqClientWrapper.main; using jjm.one.RabbitMqClientWrapper.main.core; using jjm.one.RabbitMqClientWrapper.types; @@ -10,52 +9,52 @@ namespace jjm.one.RabbitMqClientWrapper.Tests.main; /// -/// This class contains the unit tests for the class. +/// This class contains the unit tests for the class. /// public class RmqcWrapperTests { - #region private members - - private readonly RmqcWrapper _sut; - private readonly Mock _rmqcCoreMock; - private readonly Mock> _rmqcWrapperLoggingMock; - - #endregion - /// - /// The default constructor of the class. + /// The default constructor of the class. /// public RmqcWrapperTests() { _rmqcCoreMock = new Mock(); _rmqcWrapperLoggingMock = new Mock>(); - + _sut = new RmqcWrapper(_rmqcCoreMock.Object, _rmqcWrapperLoggingMock.Object); } + #region private members + + private readonly RmqcWrapper _sut; + private readonly Mock _rmqcCoreMock; + private readonly Mock> _rmqcWrapperLoggingMock; + + #endregion + #region tests #region ctor tests /// - /// Tests the constructor of the class. + /// Tests the constructor of the class. /// [Fact] public void RmqcWrapperTest_CtorTest() { // arrange + act var res = new RmqcWrapper(new RmqcSettings("Test")); - + // assert res.Settings.Hostname.Should().Be("Test"); } #endregion - + #region public members tests /// - /// Tests the getter of the Settings member. + /// Tests the getter of the Settings member. /// [Fact] public void RmqcWrapperTest_SettingsGetTest() @@ -63,7 +62,7 @@ public void RmqcWrapperTest_SettingsGetTest() // arrange var sTest = new RmqcSettings("test"); _rmqcCoreMock.Setup(x => x.Settings).Returns(sTest); - + // act var s = _sut.Settings; @@ -73,24 +72,24 @@ public void RmqcWrapperTest_SettingsGetTest() } /// - /// Tests the setter of the Settings member. + /// Tests the setter of the Settings member. /// [Fact] public void RmqcWrapperTest_SettingsSetTest() { // arrange var sTest = new RmqcSettings("test"); - _rmqcCoreMock.SetupSet(x => x.Settings=It.IsAny()).Verifiable(); - + _rmqcCoreMock.SetupSet(x => x.Settings = It.IsAny()).Verifiable(); + // act _sut.Settings = sTest; // assert - _rmqcCoreMock.VerifySet(x => x.Settings=It.IsAny(), Times.Once); + _rmqcCoreMock.VerifySet(x => x.Settings = It.IsAny(), Times.Once); } - + /// - /// Tests the getter of the Connected member. + /// Tests the getter of the Connected member. /// [Fact] public void RmqcWrapperTest_ConnectedGetTest() @@ -107,43 +106,43 @@ public void RmqcWrapperTest_ConnectedGetTest() } #endregion - + #region public methods tests /// - /// Testes the Init method. + /// Testes the Init method. /// [Fact] public void RmqcWrapperTest_InitTest() { // arrange _rmqcCoreMock.Setup(x => x.Init()); - + // act _sut.Init(); // assert _rmqcCoreMock.Verify(x => x.Init(), Times.Once); } - + /// - /// Testes the DeInit method. + /// Testes the DeInit method. /// [Fact] public void RmqcWrapperTest_DeInitTest() { // arrange _rmqcCoreMock.Setup(x => x.DeInit()); - + // act _sut.DeInit(); // assert _rmqcCoreMock.Verify(x => x.DeInit(), Times.Once); } - + /// - /// Testes the Connect method. (Test 1) + /// Testes the Connect method. (Test 1) /// [Fact] public void RmqcWrapperTest_ConnectTest1() @@ -152,15 +151,15 @@ public void RmqcWrapperTest_ConnectTest1() _rmqcCoreMock.Setup(x => x.Connect(out It.Ref.IsAny)).Returns(true); // act - var res = _sut.Connect(); - + var res = _sut.Connect(); + // assert res.Should().BeTrue(); _rmqcCoreMock.Verify(x => x.Connect(out It.Ref.IsAny), Times.Once); } - + /// - /// Testes the Connect method. (Test 2) + /// Testes the Connect method. (Test 2) /// [Fact] public void RmqcWrapperTest_ConnectTest2() @@ -176,9 +175,9 @@ public void RmqcWrapperTest_ConnectTest2() resExc.Should().BeNull(); _rmqcCoreMock.Verify(x => x.Connect(out It.Ref.IsAny), Times.Once); } - + /// - /// Testes the Connect method. (Test 3) + /// Testes the Connect method. (Test 3) /// [Fact] public void RmqcWrapperTest_ConnectTest3() @@ -202,9 +201,9 @@ public void RmqcWrapperTest_ConnectTest3() evt.Arguments.CompletionTime.Should().NotBeNull(); _rmqcCoreMock.Verify(x => x.Connect(out It.Ref.IsAny), Times.Once); } - + /// - /// Testes the Disconnect method. (Test 1) + /// Testes the Disconnect method. (Test 1) /// [Fact] public void RmqcWrapperTest_DisconnectTest1() @@ -214,16 +213,16 @@ public void RmqcWrapperTest_DisconnectTest1() // act var res = _sut.Disconnect(out var resExc); - + // assert res.Should().BeFalse(); //resExc.Should().NotBeNull(); //resExc.Should().BeOfType(); _rmqcCoreMock.Verify(x => x.Disconnect(out It.Ref.IsAny), Times.Once); } - + /// - /// Testes the Disconnect method. (Test 2) + /// Testes the Disconnect method. (Test 2) /// [Fact] public void RmqcWrapperTest_DisconnectTest2() @@ -233,14 +232,14 @@ public void RmqcWrapperTest_DisconnectTest2() // act var res = _sut.Disconnect(); - + // assert res.Should().BeTrue(); _rmqcCoreMock.Verify(x => x.Disconnect(out It.Ref.IsAny), Times.Once); } - + /// - /// Testes the Disconnect method. (Test 3) + /// Testes the Disconnect method. (Test 3) /// [Fact] public void RmqcWrapperTest_DisconnectTest3() @@ -250,15 +249,15 @@ public void RmqcWrapperTest_DisconnectTest3() // act var res = _sut.Disconnect(out var resExc); - + // assert res.Should().BeTrue(); resExc.Should().BeNull(); _rmqcCoreMock.Verify(x => x.Disconnect(out It.Ref.IsAny), Times.Once); } - + /// - /// Testes the Disconnect method. (Test 4) + /// Testes the Disconnect method. (Test 4) /// [Fact] public void RmqcWrapperTest_DisconnectTest4() @@ -282,9 +281,9 @@ public void RmqcWrapperTest_DisconnectTest4() evt.Arguments.CompletionTime.Should().NotBeNull(); _rmqcCoreMock.Verify(x => x.Disconnect(out It.Ref.IsAny), Times.Once); } - + /// - /// Testes the ReConnect method. (Test 1) + /// Testes the ReConnect method. (Test 1) /// [Fact] public void RmqcWrapperTest_ReConnectTest1() @@ -294,16 +293,16 @@ public void RmqcWrapperTest_ReConnectTest1() _rmqcCoreMock.Setup(x => x.Connect(out It.Ref.IsAny)).Returns(true); // act - var res = _sut.ReConnect(); - + var res = _sut.ReConnect(); + // assert res.Should().BeTrue(); _rmqcCoreMock.Verify(x => x.Disconnect(out It.Ref.IsAny), Times.Once); _rmqcCoreMock.Verify(x => x.Connect(out It.Ref.IsAny), Times.Once); } - + /// - /// Testes the ReConnect method. (Test 2) + /// Testes the ReConnect method. (Test 2) /// [Fact] public void RmqcWrapperTest_ReConnectTest2() @@ -313,17 +312,17 @@ public void RmqcWrapperTest_ReConnectTest2() _rmqcCoreMock.Setup(x => x.Connect(out It.Ref.IsAny)).Returns(true); // act - var res = _sut.ReConnect(out var resExc); - + var res = _sut.ReConnect(out var resExc); + // assert res.Should().BeTrue(); resExc.Should().BeNull(); _rmqcCoreMock.Verify(x => x.Disconnect(out It.Ref.IsAny), Times.Once); _rmqcCoreMock.Verify(x => x.Connect(out It.Ref.IsAny), Times.Once); } - + /// - /// Testes the ReConnect method. (Test 3) + /// Testes the ReConnect method. (Test 3) /// [Fact] public void RmqcWrapperTest_ReConnectTest3() @@ -331,7 +330,7 @@ public void RmqcWrapperTest_ReConnectTest3() // arrange _rmqcCoreMock.Setup(x => x.Disconnect(out It.Ref.IsAny)).Returns(true); _rmqcCoreMock.Setup(x => x.Connect(out It.Ref.IsAny)).Returns(true); - + // act var evt = Assert.Raises( h => _sut.ReConnectCompleted += h, @@ -347,9 +346,9 @@ public void RmqcWrapperTest_ReConnectTest3() _rmqcCoreMock.Verify(x => x.Disconnect(out It.Ref.IsAny), Times.Once); _rmqcCoreMock.Verify(x => x.Connect(out It.Ref.IsAny), Times.Once); } - + /// - /// Testes the WriteMsg method. (Test 1) + /// Testes the WriteMsg method. (Test 1) /// [Fact] public void RmqcWrapperTest_WriteMsgTest1() @@ -359,16 +358,16 @@ public void RmqcWrapperTest_WriteMsgTest1() _rmqcCoreMock.Setup(x => x.WriteMsg(ref m, out It.Ref.IsAny)).Returns(true); // act - var res = _sut.WriteMsg(ref m); - + var res = _sut.WriteMsg(ref m); + // assert res.Should().BeTrue(); - _rmqcCoreMock.Verify(x => + _rmqcCoreMock.Verify(x => x.WriteMsg(ref It.Ref.IsAny, out It.Ref.IsAny), Times.Once); } - + /// - /// Testes the WriteMsg method. (Test 2) + /// Testes the WriteMsg method. (Test 2) /// [Fact] public void RmqcWrapperTest_WriteMsgTest2() @@ -378,17 +377,17 @@ public void RmqcWrapperTest_WriteMsgTest2() _rmqcCoreMock.Setup(x => x.WriteMsg(ref m, out It.Ref.IsAny)).Returns(true); // act - var res = _sut.WriteMsg(ref m, out var resExc); - + var res = _sut.WriteMsg(ref m, out var resExc); + // assert res.Should().BeTrue(); resExc.Should().BeNull(); - _rmqcCoreMock.Verify(x => + _rmqcCoreMock.Verify(x => x.WriteMsg(ref It.Ref.IsAny, out It.Ref.IsAny), Times.Once); } - + /// - /// Testes the WriteMsg method. (Test 3) + /// Testes the WriteMsg method. (Test 3) /// [Fact] public void RmqcWrapperTest_WriteMsgTest3() @@ -411,12 +410,12 @@ public void RmqcWrapperTest_WriteMsgTest3() evt.Arguments.Successful.Should().BeTrue(); evt.Arguments.Exception.Should().BeNull(); evt.Arguments.CompletionTime.Should().NotBeNull(); - _rmqcCoreMock.Verify(x => + _rmqcCoreMock.Verify(x => x.WriteMsg(ref It.Ref.IsAny, out It.Ref.IsAny), Times.Once); } - + /// - /// Testes the ReadMsg method. (Test 1) + /// Testes the ReadMsg method. (Test 1) /// [Fact] public void RmqcWrapperTest_ReadMsgTest1() @@ -426,16 +425,16 @@ public void RmqcWrapperTest_ReadMsgTest1() _rmqcCoreMock.Setup(x => x.ReadMsg(out m, false, out It.Ref.IsAny)).Returns(true); // act - var res = _sut.ReadMsg(out m, false); - + var res = _sut.ReadMsg(out m, false); + // assert res.Should().BeTrue(); - _rmqcCoreMock.Verify(x => + _rmqcCoreMock.Verify(x => x.ReadMsg(out It.Ref.IsAny, false, out It.Ref.IsAny), Times.Once); } - + /// - /// Testes the ReadMsg method. (Test 2) + /// Testes the ReadMsg method. (Test 2) /// [Fact] public void RmqcWrapperTest_ReadMsgTest2() @@ -445,17 +444,17 @@ public void RmqcWrapperTest_ReadMsgTest2() _rmqcCoreMock.Setup(x => x.ReadMsg(out m, false, out It.Ref.IsAny)).Returns(true); // act - var res = _sut.ReadMsg(out m, false, out var resExc); - + var res = _sut.ReadMsg(out m, false, out var resExc); + // assert res.Should().BeTrue(); resExc.Should().BeNull(); - _rmqcCoreMock.Verify(x => + _rmqcCoreMock.Verify(x => x.ReadMsg(out It.Ref.IsAny, false, out It.Ref.IsAny), Times.Once); } - + /// - /// Testes the ReadMsg method. (Test 3) + /// Testes the ReadMsg method. (Test 3) /// [Fact] public void RmqcWrapperTest_ReadMsgTest3() @@ -479,12 +478,12 @@ public void RmqcWrapperTest_ReadMsgTest3() evt.Arguments.Exception.Should().BeNull(); evt.Arguments.CompletionTime.Should().NotBeNull(); evt.Arguments.Message.Should().Be(m); - _rmqcCoreMock.Verify(x => + _rmqcCoreMock.Verify(x => x.ReadMsg(out It.Ref.IsAny, false, out It.Ref.IsAny), Times.Once); } - + /// - /// Testes the AckMsg method. (Test 1) + /// Testes the AckMsg method. (Test 1) /// [Fact] public void RmqcWrapperTest_AckMsgTest1() @@ -494,16 +493,16 @@ public void RmqcWrapperTest_AckMsgTest1() _rmqcCoreMock.Setup(x => x.AckMsg(ref m, out It.Ref.IsAny)).Returns(true); // act - var res = _sut.AckMsg(ref m); - + var res = _sut.AckMsg(ref m); + // assert res.Should().BeTrue(); - _rmqcCoreMock.Verify(x => + _rmqcCoreMock.Verify(x => x.AckMsg(ref It.Ref.IsAny, out It.Ref.IsAny), Times.Once); } - + /// - /// Testes the AckMsg method. (Test 2) + /// Testes the AckMsg method. (Test 2) /// [Fact] public void RmqcWrapperTest_AckMsgTest2() @@ -513,17 +512,17 @@ public void RmqcWrapperTest_AckMsgTest2() _rmqcCoreMock.Setup(x => x.AckMsg(ref m, out It.Ref.IsAny)).Returns(true); // act - var res = _sut.AckMsg(ref m, out var resExc); - + var res = _sut.AckMsg(ref m, out var resExc); + // assert res.Should().BeTrue(); resExc.Should().BeNull(); - _rmqcCoreMock.Verify(x => + _rmqcCoreMock.Verify(x => x.AckMsg(ref It.Ref.IsAny, out It.Ref.IsAny), Times.Once); } - + /// - /// Testes the AckMsg method. (Test 3) + /// Testes the AckMsg method. (Test 3) /// [Fact] public void RmqcWrapperTest_AckMsgTest3() @@ -531,7 +530,8 @@ public void RmqcWrapperTest_AckMsgTest3() // arrange var m = new RmqcMessage(); _rmqcCoreMock.Setup(x => x.AckMsg(ref m, out It.Ref.IsAny)).Returns(true) - .Raises(x => x.AckMsgCompleted += null, new AckMsgCompletedEventArgs(true, null, TimeSpan.Zero, m.DeliveryTag)); + .Raises(x => x.AckMsgCompleted += null, + new AckMsgCompletedEventArgs(true, null, TimeSpan.Zero, m.DeliveryTag)); // act var evt = Assert.Raises( @@ -546,12 +546,12 @@ public void RmqcWrapperTest_AckMsgTest3() evt.Arguments.Exception.Should().BeNull(); evt.Arguments.CompletionTime.Should().NotBeNull(); evt.Arguments.DeliveryTag.Should().Be(m.DeliveryTag); - _rmqcCoreMock.Verify(x => + _rmqcCoreMock.Verify(x => x.AckMsg(ref It.Ref.IsAny, out It.Ref.IsAny), Times.Once); } - + /// - /// Testes the NackMsg method. (Test 1) + /// Testes the NackMsg method. (Test 1) /// [Fact] public void RmqcWrapperTest_NackMsgTest1() @@ -561,17 +561,17 @@ public void RmqcWrapperTest_NackMsgTest1() _rmqcCoreMock.Setup(x => x.NackMsg(ref m, false, out It.Ref.IsAny)).Returns(true); // act - var res = _sut.NackMsg(ref m, false, out var resExc); - + var res = _sut.NackMsg(ref m, false, out var resExc); + // assert res.Should().BeTrue(); resExc.Should().BeNull(); - _rmqcCoreMock.Verify(x => + _rmqcCoreMock.Verify(x => x.NackMsg(ref It.Ref.IsAny, false, out It.Ref.IsAny), Times.Once); } - + /// - /// Testes the NackMsg method. (Test 2) + /// Testes the NackMsg method. (Test 2) /// [Fact] public void RmqcWrapperTest_NackMsgTest2() @@ -581,17 +581,17 @@ public void RmqcWrapperTest_NackMsgTest2() _rmqcCoreMock.Setup(x => x.NackMsg(ref m, false, out It.Ref.IsAny)).Returns(true); // act - var res = _sut.NackMsg(ref m, false, out var resExc); - + var res = _sut.NackMsg(ref m, false, out var resExc); + // assert res.Should().BeTrue(); resExc.Should().BeNull(); - _rmqcCoreMock.Verify(x => + _rmqcCoreMock.Verify(x => x.NackMsg(ref It.Ref.IsAny, false, out It.Ref.IsAny), Times.Once); } - + /// - /// Testes the NackMsg method. (Test 3) + /// Testes the NackMsg method. (Test 3) /// [Fact] public void RmqcWrapperTest_NackMsgTest3() @@ -599,7 +599,8 @@ public void RmqcWrapperTest_NackMsgTest3() // arrange var m = new RmqcMessage(); _rmqcCoreMock.Setup(x => x.NackMsg(ref m, false, out It.Ref.IsAny)).Returns(true) - .Raises(x => x.NAckMsgComplete += null, new NackMsgCompletedEventArgs(true, null, TimeSpan.Zero, m.DeliveryTag)); + .Raises(x => x.NAckMsgComplete += null, + new NackMsgCompletedEventArgs(true, null, TimeSpan.Zero, m.DeliveryTag)); // act @@ -617,12 +618,12 @@ public void RmqcWrapperTest_NackMsgTest3() evt.Arguments.Exception.Should().BeNull(); evt.Arguments.CompletionTime.Should().NotBeNull(); evt.Arguments.DeliveryTag.Should().Be(m.DeliveryTag); - _rmqcCoreMock.Verify(x => + _rmqcCoreMock.Verify(x => x.NackMsg(ref It.Ref.IsAny, false, out It.Ref.IsAny), Times.Once); } - + /// - /// Testes the WaitForWriteConfirm method. (Test 1) + /// Testes the WaitForWriteConfirm method. (Test 1) /// [Fact] public void RmqcWrapperTest_WaitForWriteConfirmTest1() @@ -632,16 +633,16 @@ public void RmqcWrapperTest_WaitForWriteConfirmTest1() _rmqcCoreMock.Setup(x => x.WaitForWriteConfirm(t, out It.Ref.IsAny)).Returns(true); // act - var res = _sut.WaitForWriteConfirm(t); - + var res = _sut.WaitForWriteConfirm(t); + // assert res.Should().BeTrue(); - _rmqcCoreMock.Verify(x => + _rmqcCoreMock.Verify(x => x.WaitForWriteConfirm(It.IsAny(), out It.Ref.IsAny), Times.Once); } - + /// - /// Testes the WaitForWriteConfirm method. (Test 2) + /// Testes the WaitForWriteConfirm method. (Test 2) /// [Fact] public void RmqcWrapperTest_WaitForWriteConfirmTest2() @@ -651,17 +652,17 @@ public void RmqcWrapperTest_WaitForWriteConfirmTest2() _rmqcCoreMock.Setup(x => x.WaitForWriteConfirm(t, out It.Ref.IsAny)).Returns(true); // act - var res = _sut.WaitForWriteConfirm(t, out var resExc); - + var res = _sut.WaitForWriteConfirm(t, out var resExc); + // assert res.Should().BeTrue(); resExc.Should().BeNull(); - _rmqcCoreMock.Verify(x => + _rmqcCoreMock.Verify(x => x.WaitForWriteConfirm(It.IsAny(), out It.Ref.IsAny), Times.Once); } - + /// - /// Testes the QueuedMsgs method. (Test 1) + /// Testes the QueuedMsgs method. (Test 1) /// [Fact] public void RmqcWrapperTest_QueuedMsgsTest1() @@ -671,36 +672,36 @@ public void RmqcWrapperTest_QueuedMsgsTest1() _rmqcCoreMock.Setup(x => x.QueuedMsgs(out a, out It.Ref.IsAny)).Returns(true); // act - var res = _sut.QueuedMsgs(out a); - + var res = _sut.QueuedMsgs(out a); + // assert res.Should().BeTrue(); - _rmqcCoreMock.Verify(x => + _rmqcCoreMock.Verify(x => x.QueuedMsgs(out It.Ref.IsAny, out It.Ref.IsAny), Times.Once); } - + /// - /// Testes the QueuedMsgs method. (Test 2) + /// Testes the QueuedMsgs method. (Test 2) /// [Fact] public void RmqcWrapperTest_QueuedMsgsTest2() { // arrange - uint? a = 0; + uint? a = 0; _rmqcCoreMock.Setup(x => x.QueuedMsgs(out a, out It.Ref.IsAny)).Returns(true); // act - var res = _sut.QueuedMsgs(out a, out var resExc); - + var res = _sut.QueuedMsgs(out a, out var resExc); + // assert res.Should().BeTrue(); resExc.Should().BeNull(); - _rmqcCoreMock.Verify(x => + _rmqcCoreMock.Verify(x => x.QueuedMsgs(out It.Ref.IsAny, out It.Ref.IsAny), Times.Once); } - + /// - /// Testes the QueuedMsgs method. (Test 3) + /// Testes the QueuedMsgs method. (Test 3) /// [Fact] public void RmqcWrapperTest_QueuedMsgsTest3() @@ -708,7 +709,7 @@ public void RmqcWrapperTest_QueuedMsgsTest3() // arrange uint? a = 0; _rmqcCoreMock.Setup(x => x.QueuedMsgs(out a, out It.Ref.IsAny)).Returns(true) - .Raises(x => x.QueuedMsgsCompleted += null, new QueuedMsgsCompletedEventArgs(true, null, TimeSpan.Zero, amount: a)); + .Raises(x => x.QueuedMsgsCompleted += null, new QueuedMsgsCompletedEventArgs(true, null, TimeSpan.Zero, a)); // act @@ -724,12 +725,11 @@ public void RmqcWrapperTest_QueuedMsgsTest3() evt.Arguments.Exception.Should().BeNull(); evt.Arguments.CompletionTime.Should().NotBeNull(); evt.Arguments.Amount.Should().Be(a); - _rmqcCoreMock.Verify(x => + _rmqcCoreMock.Verify(x => x.QueuedMsgs(out It.Ref.IsAny, out It.Ref.IsAny), Times.Once); } #endregion - + #endregion -} - \ No newline at end of file +} \ No newline at end of file diff --git a/src/jjm.one.RabbitMqClientWrapper.Tests/main/core/RmqcCoreTests.cs b/src/jjm.one.RabbitMqClientWrapper.Tests/main/core/RmqcCoreTests.cs index d3ec7b8..6df8148 100644 --- a/src/jjm.one.RabbitMqClientWrapper.Tests/main/core/RmqcCoreTests.cs +++ b/src/jjm.one.RabbitMqClientWrapper.Tests/main/core/RmqcCoreTests.cs @@ -1,5 +1,4 @@ using System; -using FluentAssertions; using jjm.one.RabbitMqClientWrapper.main.core; using jjm.one.RabbitMqClientWrapper.types; using jjm.one.RabbitMqClientWrapper.types.events; @@ -11,25 +10,14 @@ namespace jjm.one.RabbitMqClientWrapper.Tests.main.core; /// -/// This class contains the unit tests for the class. +/// This class contains the unit tests for the class. /// public class RmqcCoreTests { - #region private members - - private RmqcCore _sut; - private readonly Mock _connectionFactoryMock; - private readonly Mock _connectionMock; - private readonly Mock _channelMock; - private readonly Mock> _rmqcCoreLoggingMock; - private readonly Mock _settingsMock; - - #endregion - #region ctors /// - /// The default constructor of the class. + /// The default constructor of the class. /// public RmqcCoreTests() { @@ -45,48 +33,59 @@ public RmqcCoreTests() #endregion + #region private members + + private RmqcCore _sut; + private readonly Mock _connectionFactoryMock; + private readonly Mock _connectionMock; + private readonly Mock _channelMock; + private readonly Mock> _rmqcCoreLoggingMock; + private readonly Mock _settingsMock; + + #endregion + #region tests #region ctor tests /// - /// Tests the constructor of the class. (Test 1) + /// Tests the constructor of the class. (Test 1) /// [Fact] public void RmqcWrapperTest_CtorTest1() { // arrange - + // act _sut = new RmqcCore(_settingsMock.Object); - + // assert _sut.Should().NotBeNull(); _sut.Settings.Should().NotBeNull(); } - + /// - /// Tests the constructor of the class. (Test 2) + /// Tests the constructor of the class. (Test 2) /// [Fact] public void RmqcWrapperTest_CtorTest2() { // arrange - + // act _sut = new RmqcCore(_settingsMock.Object, _rmqcCoreLoggingMock.Object); - + // assert _sut.Should().NotBeNull(); _sut.Settings.Should().NotBeNull(); } #endregion - + #region public members tests - + /// - /// Tests the getter of the Settings member. (Test 1) + /// Tests the getter of the Settings member. (Test 1) /// [Fact] public void RmqcWrapperTest_SettingsGetTest1() @@ -102,7 +101,7 @@ public void RmqcWrapperTest_SettingsGetTest1() // act _sut = new RmqcCore(_settingsMock.Object); - + // assert _sut.Settings.Should().NotBeNull(); _sut.Settings.Hostname.Should().Be("Test"); @@ -113,9 +112,9 @@ public void RmqcWrapperTest_SettingsGetTest1() _sut.Settings.Exchange.Should().Be("Test"); _sut.Settings.Queue.Should().Be("Test"); } - + /// - /// Tests the setter of the Settings member. (Test 1) + /// Tests the setter of the Settings member. (Test 1) /// [Fact] public void RmqcWrapperTest_SettingsSetTest1() @@ -144,9 +143,9 @@ public void RmqcWrapperTest_SettingsSetTest1() _sut.Settings.Exchange.Should().Be("Test2"); _sut.Settings.Queue.Should().Be("Test2"); } - + /// - /// Tests the setter of the Settings member. (Test 2) + /// Tests the setter of the Settings member. (Test 2) /// [Fact] public void RmqcWrapperTest_SettingsSetTest2() @@ -162,7 +161,7 @@ public void RmqcWrapperTest_SettingsSetTest2() _connectionMock.Setup(x => x.IsOpen).Returns(true); _connectionMock.Setup(x => x.Close()); _connectionMock.Setup(x => x.Dispose()); - + // act _sut.Settings = settingsMockTemp.Object; @@ -175,9 +174,9 @@ public void RmqcWrapperTest_SettingsSetTest2() _connectionMock.Verify(x => x.Close(), Times.Once); _connectionMock.Verify(x => x.Dispose(), Times.Once); } - + /// - /// Tests the getter of the Connected member. (Test 1) + /// Tests the getter of the Connected member. (Test 1) /// [Fact] public void RmqcWrapperTest_ConnectedGetTest1() @@ -194,9 +193,9 @@ public void RmqcWrapperTest_ConnectedGetTest1() _channelMock.Verify(x => x.IsOpen, Times.Once); b.Should().BeTrue(); } - + /// - /// Tests the getter of the Connected member. (Test 2) + /// Tests the getter of the Connected member. (Test 2) /// [Fact] public void RmqcWrapperTest_ConnectedGetTest2() @@ -213,9 +212,9 @@ public void RmqcWrapperTest_ConnectedGetTest2() _channelMock.Verify(x => x.IsOpen, Times.Never); b.Should().BeFalse(); } - + /// - /// Tests the getter of the Connected member. (Test 3) + /// Tests the getter of the Connected member. (Test 3) /// [Fact] public void RmqcWrapperTest_ConnectedGetTest3() @@ -234,7 +233,7 @@ public void RmqcWrapperTest_ConnectedGetTest3() } /// - /// Tests the getter of the Connected member. (Test 4) + /// Tests the getter of the Connected member. (Test 4) /// [Fact] public void RmqcWrapperTest_ConnectedGetTest4() @@ -255,7 +254,7 @@ public void RmqcWrapperTest_ConnectedGetTest4() } /// - /// Tests the getter of the Connected member. (Test 5) + /// Tests the getter of the Connected member. (Test 5) /// [Fact] public void RmqcWrapperTest_ConnectedGetTest5() @@ -274,9 +273,9 @@ public void RmqcWrapperTest_ConnectedGetTest5() _channelMock.Verify(x => x.IsOpen, Times.Never); b.Should().BeFalse(); } - + /// - /// Tests the getter of the Connected member. (Test 6) + /// Tests the getter of the Connected member. (Test 6) /// [Fact] public void RmqcWrapperTest_ConnectedGetTest6() @@ -295,16 +294,15 @@ public void RmqcWrapperTest_ConnectedGetTest6() _channelMock.Verify(x => x.IsOpen, Times.Never); b.Should().BeFalse(); } - - + #endregion - + #region public methods tests #region init & de-init /// - /// Testes the Init method. + /// Testes the Init method. /// [Fact] public void RmqcWrapperTest_InitTest() @@ -313,7 +311,7 @@ public void RmqcWrapperTest_InitTest() _settingsMock.Setup(x => x.Hostname).Returns("test"); _settingsMock.Setup(x => x.Username).Returns("TestUser"); _settingsMock.Setup(x => x.Password).Returns("TestPwd"); - + try { // act @@ -325,9 +323,9 @@ public void RmqcWrapperTest_InitTest() Assert.Fail(exc.Message); } } - + /// - /// Testes the DeInit method. + /// Testes the DeInit method. /// [Fact] public void RmqcWrapperTest_DeInitTest() @@ -351,7 +349,7 @@ public void RmqcWrapperTest_DeInitTest() #region Connect /// - /// Testes the Connect method. (Test 1) + /// Testes the Connect method. (Test 1) /// [Fact] public void RmqcWrapperTest_ConnectTest1() @@ -369,9 +367,9 @@ public void RmqcWrapperTest_ConnectTest1() res.Should().BeTrue(); resExc.Should().BeNull(); } - + /// - /// Testes the Connect method. (Test 2) + /// Testes the Connect method. (Test 2) /// [Fact] public void RmqcWrapperTest_ConnectTest2() @@ -389,9 +387,9 @@ public void RmqcWrapperTest_ConnectTest2() res.Should().BeFalse(); resExc.Should().BeOfType(); } - + /// - /// Testes the Connect method. (Test 3) + /// Testes the Connect method. (Test 3) /// [Fact] public void RmqcWrapperTest_ConnectTest3() @@ -409,9 +407,9 @@ public void RmqcWrapperTest_ConnectTest3() res.Should().BeFalse(); resExc.Should().BeOfType(); } - + /// - /// Testes the Connect method. (Test 4) + /// Testes the Connect method. (Test 4) /// [Fact] public void RmqcWrapperTest_ConnectTest4() @@ -431,9 +429,9 @@ public void RmqcWrapperTest_ConnectTest4() res.Should().BeFalse(); resExc.Should().BeOfType(); } - + /// - /// Testes the Connect method. (Test 5) + /// Testes the Connect method. (Test 5) /// [Fact] public void RmqcWrapperTest_ConnectTest5() @@ -455,9 +453,9 @@ public void RmqcWrapperTest_ConnectTest5() evt.Arguments.Exception.Should().BeNull(); evt.Arguments.CompletionTime.Should().HaveValue(); } - + /// - /// Testes the Connect method. (Test 6) + /// Testes the Connect method. (Test 6) /// [Fact] public void RmqcWrapperTest_ConnectTest6() @@ -479,9 +477,9 @@ public void RmqcWrapperTest_ConnectTest6() evt.Arguments.Exception.Should().BeOfType(); evt.Arguments.CompletionTime.Should().HaveValue(); } - + /// - /// Testes the Connect method. (Test 7) + /// Testes the Connect method. (Test 7) /// [Fact] public void RmqcWrapperTest_ConnectTest7() @@ -503,9 +501,9 @@ public void RmqcWrapperTest_ConnectTest7() evt.Arguments.Exception.Should().BeOfType(); evt.Arguments.CompletionTime.Should().HaveValue(); } - + /// - /// Testes the Connect method. (Test 8) + /// Testes the Connect method. (Test 8) /// [Fact] public void RmqcWrapperTest_ConnectTest8() @@ -531,7 +529,7 @@ public void RmqcWrapperTest_ConnectTest8() } /// - /// Testes the Connect method. (Test 9) + /// Testes the Connect method. (Test 9) /// [Fact] public void RmqcWrapperTest_ConnectTest9() @@ -551,9 +549,9 @@ public void RmqcWrapperTest_ConnectTest9() evt.Sender.Should().Be(_sut); evt.Arguments.Status.Should().BeTrue(); } - + /// - /// Testes the Connect method. (Test 10) + /// Testes the Connect method. (Test 10) /// [Fact] public void RmqcWrapperTest_ConnectTest10() @@ -576,9 +574,9 @@ public void RmqcWrapperTest_ConnectTest10() evt.Sender.Should().Be(_sut); evt.Arguments.Status.Should().BeFalse(); } - + /// - /// Testes the Connect method. (Test 11) + /// Testes the Connect method. (Test 11) /// [Fact] public void RmqcWrapperTest_ConnectTest11() @@ -601,13 +599,13 @@ public void RmqcWrapperTest_ConnectTest11() evt.Sender.Should().Be(_sut); evt.Arguments.Status.Should().BeFalse(); } - + #endregion #region Disconnect /// - /// Testes the Disconnect method. (Test 1) + /// Testes the Disconnect method. (Test 1) /// [Fact] public void RmqcWrapperTest_DisconnectTest1() @@ -622,7 +620,7 @@ public void RmqcWrapperTest_DisconnectTest1() // act var res = _sut.Disconnect(out var resExc); - + // assert res.Should().BeTrue(); resExc.Should().BeNull(); @@ -635,7 +633,7 @@ public void RmqcWrapperTest_DisconnectTest1() } /// - /// Testes the Disconnect method. (Test 2) + /// Testes the Disconnect method. (Test 2) /// [Fact] public void RmqcWrapperTest_DisconnectTest2() @@ -650,7 +648,7 @@ public void RmqcWrapperTest_DisconnectTest2() // act var res = _sut.Disconnect(out var resExc); - + // assert res.Should().BeFalse(); resExc.Should().NotBeNull(); @@ -661,9 +659,9 @@ public void RmqcWrapperTest_DisconnectTest2() _connectionMock.Verify(x => x.Close(), Times.Never); _connectionMock.Verify(x => x.Dispose(), Times.Never); } - + /// - /// Testes the Disconnect method. (Test 3) + /// Testes the Disconnect method. (Test 3) /// [Fact] public void RmqcWrapperTest_DisconnectTest3() @@ -678,7 +676,7 @@ public void RmqcWrapperTest_DisconnectTest3() // act var res = _sut.Disconnect(out var resExc); - + // assert res.Should().BeFalse(); resExc.Should().NotBeNull(); @@ -691,7 +689,7 @@ public void RmqcWrapperTest_DisconnectTest3() } /// - /// Testes the Disconnect method. (Test 4) + /// Testes the Disconnect method. (Test 4) /// [Fact] public void RmqcWrapperTest_DisconnectTest4() @@ -706,7 +704,7 @@ public void RmqcWrapperTest_DisconnectTest4() // act var res = _sut.Disconnect(out var resExc); - + // assert res.Should().BeTrue(); resExc.Should().BeNull(); @@ -717,9 +715,9 @@ public void RmqcWrapperTest_DisconnectTest4() _connectionMock.Verify(x => x.Close(), Times.Once); _connectionMock.Verify(x => x.Dispose(), Times.Once); } - + /// - /// Testes the Disconnect method. (Test 5) + /// Testes the Disconnect method. (Test 5) /// [Fact] public void RmqcWrapperTest_DisconnectTest5() @@ -734,7 +732,7 @@ public void RmqcWrapperTest_DisconnectTest5() // act var res = _sut.Disconnect(out var resExc); - + // assert res.Should().BeTrue(); resExc.Should().BeNull(); @@ -745,9 +743,9 @@ public void RmqcWrapperTest_DisconnectTest5() _connectionMock.Verify(x => x.Close(), Times.Never); _connectionMock.Verify(x => x.Dispose(), Times.Once); } - + /// - /// Testes the Disconnect method. (Test 6) + /// Testes the Disconnect method. (Test 6) /// [Fact] public void RmqcWrapperTest_DisconnectTest6() @@ -773,13 +771,13 @@ public void RmqcWrapperTest_DisconnectTest6() evt.Arguments.Exception.Should().BeNull(); evt.Arguments.CompletionTime.Should().HaveValue(); } - + #endregion #region WriteMsg /// - /// Testes the WriteMsg method. (Test 1) + /// Testes the WriteMsg method. (Test 1) /// [Fact] public void RmqcWrapperTest_WriteMsgTest1() @@ -793,8 +791,8 @@ public void RmqcWrapperTest_WriteMsgTest1() It.IsAny(), It.IsAny>())); // act - var res = _sut.WriteMsg(ref m, out var resExc); - + var res = _sut.WriteMsg(ref m, out var resExc); + // assert _connectionMock.Verify(x => x.IsOpen, Times.AtMostOnce); _channelMock.Verify(x => x.IsOpen, Times.AtMostOnce); @@ -806,7 +804,7 @@ public void RmqcWrapperTest_WriteMsgTest1() } /// - /// Testes the WriteMsg method. (Test 2) + /// Testes the WriteMsg method. (Test 2) /// [Fact] public void RmqcWrapperTest_WriteMsgTest2() @@ -820,8 +818,8 @@ public void RmqcWrapperTest_WriteMsgTest2() It.IsAny(), It.IsAny>())); // act - var res = _sut.WriteMsg(ref m, out var resExc); - + var res = _sut.WriteMsg(ref m, out var resExc); + // assert _connectionMock.Verify(x => x.IsOpen, Times.AtMostOnce); _channelMock.Verify(x => x.IsOpen, Times.AtMostOnce); @@ -837,7 +835,7 @@ public void RmqcWrapperTest_WriteMsgTest2() #region ReadMsg /// - /// Testes the ReadMsg method. (Test 1) + /// Testes the ReadMsg method. (Test 1) /// [Fact(Skip = "Not properly implemented!")] public void RmqcWrapperTest_ReadMsgTest1() @@ -850,8 +848,8 @@ public void RmqcWrapperTest_ReadMsgTest1() _channelMock.Setup(x => x.BasicGet(It.IsAny(), It.IsAny())).Returns(bgr); // act - var res = _sut.ReadMsg(out var resMsg, false, out var resExc); - + var res = _sut.ReadMsg(out var resMsg, false, out var resExc); + // assert _connectionMock.Verify(x => x.IsOpen, Times.AtMostOnce); _channelMock.Verify(x => x.IsOpen, Times.AtMostOnce); @@ -862,7 +860,7 @@ public void RmqcWrapperTest_ReadMsgTest1() } /// - /// Testes the ReadMsg method. (Test 2) + /// Testes the ReadMsg method. (Test 2) /// [Fact] public void RmqcWrapperTest_ReadMsgTest2() @@ -875,8 +873,8 @@ public void RmqcWrapperTest_ReadMsgTest2() _channelMock.Setup(x => x.BasicGet(It.IsAny(), It.IsAny())).Returns(bgr); // act - var res = _sut.ReadMsg(out var resMsg, false, out var resExc); - + var res = _sut.ReadMsg(out var resMsg, false, out var resExc); + // assert _connectionMock.Verify(x => x.IsOpen, Times.AtMostOnce); _channelMock.Verify(x => x.IsOpen, Times.AtMostOnce); @@ -885,9 +883,9 @@ public void RmqcWrapperTest_ReadMsgTest2() resMsg.Should().BeNull(); resExc.Should().BeOfType(); } - + /// - /// Testes the ReadMsg method. (Test 3) + /// Testes the ReadMsg method. (Test 3) /// [Fact] public void RmqcWrapperTest_ReadMsgTest3() @@ -900,8 +898,8 @@ public void RmqcWrapperTest_ReadMsgTest3() _channelMock.Setup(x => x.BasicGet(It.IsAny(), It.IsAny())).Returns(value: null!); // act - var res = _sut.ReadMsg(out var resMsg, false, out var resExc); - + var res = _sut.ReadMsg(out var resMsg, false, out var resExc); + // assert _connectionMock.Verify(x => x.IsOpen, Times.Once); _channelMock.Verify(x => x.IsOpen, Times.Once); @@ -916,7 +914,7 @@ public void RmqcWrapperTest_ReadMsgTest3() #region AckMsg /// - /// Testes the AckMsg method. (Test 1) + /// Testes the AckMsg method. (Test 1) /// [Fact] public void RmqcWrapperTest_AckMsgTest1() @@ -928,8 +926,8 @@ public void RmqcWrapperTest_AckMsgTest1() _channelMock.Setup(x => x.BasicAck(It.IsAny(), It.IsAny())); // act - var res = _sut.AckMsg(ref m, out var resExc); - + var res = _sut.AckMsg(ref m, out var resExc); + // assert _connectionMock.Verify(x => x.IsOpen, Times.AtMostOnce); _channelMock.Verify(x => x.IsOpen, Times.AtMostOnce); @@ -939,7 +937,7 @@ public void RmqcWrapperTest_AckMsgTest1() } /// - /// Testes the AckMsg method. (Test 2) + /// Testes the AckMsg method. (Test 2) /// [Fact] public void RmqcWrapperTest_AckMsgTest2() @@ -951,8 +949,8 @@ public void RmqcWrapperTest_AckMsgTest2() _channelMock.Setup(x => x.BasicAck(It.IsAny(), It.IsAny())); // act - var res = _sut.AckMsg(ref m, out var resExc); - + var res = _sut.AckMsg(ref m, out var resExc); + // assert _connectionMock.Verify(x => x.IsOpen, Times.AtMostOnce); _channelMock.Verify(x => x.IsOpen, Times.AtMostOnce); @@ -966,7 +964,7 @@ public void RmqcWrapperTest_AckMsgTest2() #region NackMsg /// - /// Testes the NackMsg method. (Test 1) + /// Testes the NackMsg method. (Test 1) /// [Fact] public void RmqcWrapperTest_NackMsgTest1() @@ -975,21 +973,21 @@ public void RmqcWrapperTest_NackMsgTest1() var m = new RmqcMessage(); _connectionMock.Setup(x => x.IsOpen).Returns(true); _channelMock.Setup(x => x.IsOpen).Returns(true); - _channelMock.Setup(x => x.BasicNack(It.IsAny(), It.IsAny(),It.IsAny())); + _channelMock.Setup(x => x.BasicNack(It.IsAny(), It.IsAny(), It.IsAny())); // act - var res = _sut.NackMsg(ref m, false, out var resExc); - + var res = _sut.NackMsg(ref m, false, out var resExc); + // assert _connectionMock.Verify(x => x.IsOpen, Times.AtMostOnce); _channelMock.Verify(x => x.IsOpen, Times.AtMostOnce); - _channelMock.Verify(x => x.BasicNack(It.IsAny(), It.IsAny(),It.IsAny()), Times.Once()); + _channelMock.Verify(x => x.BasicNack(It.IsAny(), It.IsAny(), It.IsAny()), Times.Once()); res.Should().BeTrue(); resExc.Should().BeNull(); } /// - /// Testes the NackMsg method. (Test 2) + /// Testes the NackMsg method. (Test 2) /// [Fact] public void RmqcWrapperTest_NackMsgTest2() @@ -998,15 +996,15 @@ public void RmqcWrapperTest_NackMsgTest2() var m = new RmqcMessage(); _connectionMock.Setup(x => x.IsOpen).Returns(false); _channelMock.Setup(x => x.IsOpen).Returns(false); - _channelMock.Setup(x => x.BasicNack(It.IsAny(), It.IsAny(),It.IsAny())); + _channelMock.Setup(x => x.BasicNack(It.IsAny(), It.IsAny(), It.IsAny())); // act - var res = _sut.NackMsg(ref m, false, out var resExc); - + var res = _sut.NackMsg(ref m, false, out var resExc); + // assert _connectionMock.Verify(x => x.IsOpen, Times.AtMostOnce); _channelMock.Verify(x => x.IsOpen, Times.AtMostOnce); - _channelMock.Verify(x => x.BasicNack(It.IsAny(), It.IsAny(),It.IsAny()), Times.Never()); + _channelMock.Verify(x => x.BasicNack(It.IsAny(), It.IsAny(), It.IsAny()), Times.Never()); res.Should().BeFalse(); resExc.Should().BeOfType(); } @@ -1016,7 +1014,7 @@ public void RmqcWrapperTest_NackMsgTest2() #region WaitForWriteConfirm /// - /// Testes the WaitForWriteConfirm method. (Test 1) + /// Testes the WaitForWriteConfirm method. (Test 1) /// [Fact] public void RmqcWrapperTest_WaitForWriteConfirmTest1() @@ -1028,8 +1026,8 @@ public void RmqcWrapperTest_WaitForWriteConfirmTest1() _channelMock.Setup(x => x.WaitForConfirms(It.IsAny())).Returns(true); // act - var res = _sut.WaitForWriteConfirm(t, out var resExc); - + var res = _sut.WaitForWriteConfirm(t, out var resExc); + // assert _connectionMock.Verify(x => x.IsOpen, Times.AtMostOnce); _channelMock.Verify(x => x.IsOpen, Times.AtMostOnce); @@ -1039,7 +1037,7 @@ public void RmqcWrapperTest_WaitForWriteConfirmTest1() } /// - /// Testes the WaitForWriteConfirm method. (Test 2) + /// Testes the WaitForWriteConfirm method. (Test 2) /// [Fact] public void RmqcWrapperTest_WaitForWriteConfirmTest2() @@ -1051,8 +1049,8 @@ public void RmqcWrapperTest_WaitForWriteConfirmTest2() _channelMock.Setup(x => x.WaitForConfirms(It.IsAny())).Returns(true); // act - var res = _sut.WaitForWriteConfirm(t, out var resExc); - + var res = _sut.WaitForWriteConfirm(t, out var resExc); + // assert _connectionMock.Verify(x => x.IsOpen, Times.AtMostOnce); _channelMock.Verify(x => x.IsOpen, Times.AtMostOnce); @@ -1066,7 +1064,7 @@ public void RmqcWrapperTest_WaitForWriteConfirmTest2() #region QueuedMsgs /// - /// Testes the QueuedMsgs method. (Test 1) + /// Testes the QueuedMsgs method. (Test 1) /// [Fact] public void RmqcWrapperTest_QueuedMsgsTest1() @@ -1078,8 +1076,8 @@ public void RmqcWrapperTest_QueuedMsgsTest1() _channelMock.Setup(x => x.MessageCount(It.IsAny())).Returns(42); // act - var res = _sut.QueuedMsgs(out a, out var resExc); - + var res = _sut.QueuedMsgs(out a, out var resExc); + // assert _connectionMock.Verify(x => x.IsOpen, Times.AtMostOnce); _channelMock.Verify(x => x.IsOpen, Times.AtMostOnce); @@ -1088,9 +1086,9 @@ public void RmqcWrapperTest_QueuedMsgsTest1() a.Should().Be(42); resExc.Should().BeNull(); } - + /// - /// Testes the QueuedMsgs method. (Test 2) + /// Testes the QueuedMsgs method. (Test 2) /// [Fact] public void RmqcWrapperTest_QueuedMsgsTest2() @@ -1102,8 +1100,8 @@ public void RmqcWrapperTest_QueuedMsgsTest2() _channelMock.Setup(x => x.MessageCount(It.IsAny())).Returns(42); // act - var res = _sut.QueuedMsgs(out a, out var resExc); - + var res = _sut.QueuedMsgs(out a, out var resExc); + // assert _connectionMock.Verify(x => x.IsOpen, Times.AtMostOnce); _channelMock.Verify(x => x.IsOpen, Times.AtMostOnce); @@ -1114,8 +1112,8 @@ public void RmqcWrapperTest_QueuedMsgsTest2() } #endregion - + #endregion - + #endregion } \ No newline at end of file diff --git a/src/jjm.one.RabbitMqClientWrapper.Tests/types/MessageTests.cs b/src/jjm.one.RabbitMqClientWrapper.Tests/types/MessageTests.cs index 758135b..82ea56c 100644 --- a/src/jjm.one.RabbitMqClientWrapper.Tests/types/MessageTests.cs +++ b/src/jjm.one.RabbitMqClientWrapper.Tests/types/MessageTests.cs @@ -1,12 +1,11 @@ using System; -using FluentAssertions; using jjm.one.RabbitMqClientWrapper.types; using RabbitMQ.Client; namespace jjm.one.RabbitMqClientWrapper.Tests.types; /// -/// This class contains the unit tests for the class. +/// This class contains the unit tests for the class. /// public class MessageTests { @@ -15,14 +14,14 @@ public class MessageTests #region ctor tests /// - /// Tests the default constructor of the class. + /// Tests the default constructor of the class. /// [Fact] public void MessageTest_DefaultCtorTest() { // arrange RmqcMessage m = null!; - + try { // act @@ -33,20 +32,20 @@ public void MessageTest_DefaultCtorTest() // assert 1 Assert.Fail(exc.Message); } - + // assert 2 m.Should().NotBeNull(); } - + /// - /// Tests the constructor of the class with as inputs. + /// Tests the constructor of the class with as inputs. /// [Fact] public void MessageTest_CtorNullTest() { // arrange RmqcMessage m = null!; - + try { // act @@ -57,22 +56,22 @@ public void MessageTest_CtorNullTest() // assert 1 Assert.Fail(exc.Message); } - + // assert 2 m.Should().NotBeNull(); } - + /// - /// Tests the constructor of the class. + /// Tests the constructor of the class. /// [Fact] public void MessageTest_CtorTest() { // arrange RmqcMessage m = null!; - var r = + var r = new BasicGetResult(0, false, "", "", 0, null, null); - + try { // act @@ -83,7 +82,7 @@ public void MessageTest_CtorTest() // assert 1 Assert.Fail(exc.Message); } - + // assert 2 m.Should().NotBeNull(); } @@ -93,14 +92,14 @@ public void MessageTest_CtorTest() #region public members tests /// - /// Tests the getter of the DeliveryTag member. + /// Tests the getter of the DeliveryTag member. /// [Fact] public void MessageTest_DeliveryTagGetTest() { // arrange var m = new RmqcMessage( - new BasicGetResult(42, true, "TEST-EX","TEST-RK", 69, + new BasicGetResult(42, true, "TEST-EX", "TEST-RK", 69, null, new ReadOnlyMemory())); // act @@ -109,16 +108,16 @@ public void MessageTest_DeliveryTagGetTest() // assert res.Should().Be(42); } - + /// - /// Tests the getter of the RoutingKey member. + /// Tests the getter of the RoutingKey member. /// [Fact] public void MessageTest_RoutingKeyGetTest() { // arrange var m = new RmqcMessage( - new BasicGetResult(42, true, "TEST-EX","TEST-RK", 69, + new BasicGetResult(42, true, "TEST-EX", "TEST-RK", 69, null, new ReadOnlyMemory())); // act @@ -129,14 +128,14 @@ public void MessageTest_RoutingKeyGetTest() } /// - /// Tests the setter of the RoutingKey member. (Test 1) + /// Tests the setter of the RoutingKey member. (Test 1) /// [Fact] public void MessageTest_RoutingKeySetTest1() { // arrange var m = new RmqcMessage( - new BasicGetResult(42, true, "TEST-EX",string.Empty, 69, + new BasicGetResult(42, true, "TEST-EX", string.Empty, 69, null, new ReadOnlyMemory())) { // act @@ -148,9 +147,9 @@ public void MessageTest_RoutingKeySetTest1() // assert res.Should().Be("TEST-RK"); } - + /// - /// Tests the setter of the RoutingKey member. (Testm2) + /// Tests the setter of the RoutingKey member. (Testm2) /// [Fact] public void MessageTest_RoutingKeySetTest2() @@ -167,16 +166,16 @@ public void MessageTest_RoutingKeySetTest2() // assert res.Should().Be("TEST-RK"); } - + /// - /// Tests the getter of the BasicProperties member. + /// Tests the getter of the BasicProperties member. /// [Fact(Skip = "Not properly implemented Test.")] public void MessageTest_BasicPropertiesGetTest() { // arrange var m = new RmqcMessage( - new BasicGetResult(42, true, "TEST-EX","TEST-RK", 69, + new BasicGetResult(42, true, "TEST-EX", "TEST-RK", 69, null, new ReadOnlyMemory())); // act @@ -185,9 +184,9 @@ public void MessageTest_BasicPropertiesGetTest() // assert res.Should().BeNull(); } - + /// - /// Tests the setter of the BasicProperties member. + /// Tests the setter of the BasicProperties member. /// [Fact(Skip = "Not properly implemented Test.")] public void MessageTest_BasicPropertiesSetTest() @@ -195,7 +194,7 @@ public void MessageTest_BasicPropertiesSetTest() // arrange IBasicProperties? bP = null; var m = new RmqcMessage( - new BasicGetResult(42, true, "TEST-EX","TEST-RK", 69, + new BasicGetResult(42, true, "TEST-EX", "TEST-RK", 69, null, new ReadOnlyMemory())) { // act @@ -207,9 +206,9 @@ public void MessageTest_BasicPropertiesSetTest() // assert res.Should().Be(bP); } - + /// - /// Tests the getter of the Body member. + /// Tests the getter of the Body member. /// [Fact] public void MessageTest_BodyGetSetTest() @@ -217,25 +216,26 @@ public void MessageTest_BodyGetSetTest() // arrange var b = Array.Empty(); var m = new RmqcMessage( - new BasicGetResult(42, true, "TEST-EX","TEST-RK", 69, + new BasicGetResult(42, true, "TEST-EX", "TEST-RK", 69, null, b)); // act var res = m.BodyArray; - + // assert res.Should().BeEquivalentTo(b); } - + /// - /// Tests the setter of the Body member. (Test 1) + /// Tests the setter of the Body member. (Test 1) /// [Fact] public void MessageTest_BodySetTest1() { // arrange - var b = Array.Empty();; + var b = Array.Empty(); + ; var m = new RmqcMessage( - new BasicGetResult(42, true, "TEST-EX","TEST-RK", 69, + new BasicGetResult(42, true, "TEST-EX", "TEST-RK", 69, null, null)) { // act @@ -249,7 +249,7 @@ public void MessageTest_BodySetTest1() } /// - /// Tests the setter of the Body member. (Test 2) + /// Tests the setter of the Body member. (Test 2) /// [Fact] public void MessageTest_BodySetTest2() @@ -268,16 +268,16 @@ public void MessageTest_BodySetTest2() res.Should().NotBeNull(); res.Should().BeEquivalentTo(b); } - + /// - /// Tests the setter of the Body member. (Test 3) + /// Tests the setter of the Body member. (Test 3) /// [Fact] public void MessageTest_BodySetTest3() { // arrange var m = new RmqcMessage( - new BasicGetResult(42, true, "TEST-EX","TEST-RK", 69, + new BasicGetResult(42, true, "TEST-EX", "TEST-RK", 69, null, null)) { // act @@ -285,13 +285,13 @@ public void MessageTest_BodySetTest3() }; var res = m.BodyArray; - + // assert res.Should().BeNull(); } - + /// - /// Tests the setter of the Body member. (Test 4) + /// Tests the setter of the Body member. (Test 4) /// [Fact] public void MessageTest_BodySetTest4() @@ -308,8 +308,8 @@ public void MessageTest_BodySetTest4() // assert res.Should().BeNull(); } - + #endregion - + #endregion } \ No newline at end of file diff --git a/src/jjm.one.RabbitMqClientWrapper.Tests/types/SettingsTests.cs b/src/jjm.one.RabbitMqClientWrapper.Tests/types/SettingsTests.cs index 8ce45a9..5946d9e 100644 --- a/src/jjm.one.RabbitMqClientWrapper.Tests/types/SettingsTests.cs +++ b/src/jjm.one.RabbitMqClientWrapper.Tests/types/SettingsTests.cs @@ -3,7 +3,7 @@ namespace jjm.one.RabbitMqClientWrapper.Tests.types; /// -/// This class contains the unit tests for the class. +/// This class contains the unit tests for the class. /// public class SettingsTests { @@ -12,7 +12,7 @@ public class SettingsTests #region ctor tests /// - /// Tests the default constructor of the class. + /// Tests the default constructor of the class. /// [Fact] public void SettingsTest_DefaultCtorTest() @@ -29,12 +29,12 @@ public void SettingsTest_DefaultCtorTest() } /// - /// Tests the constructor of the class with as inputs. + /// Tests the constructor of the class with as inputs. /// [Fact] public void SettingsTest_CtorNullTest() { - var s = new RmqcSettings(null, null, null, null, null, null ,null); + var s = new RmqcSettings(null); Assert.Equal("localhost", s.Hostname); Assert.Equal(5672, s.Port); @@ -46,7 +46,7 @@ public void SettingsTest_CtorNullTest() } /// - /// Tests the constructor of the class. + /// Tests the constructor of the class. /// [Fact] public void SettingsTest_CtorTest() @@ -65,9 +65,9 @@ public void SettingsTest_CtorTest() #endregion #region public override tests - + /// - /// Tests the Equals method of the class. + /// Tests the Equals method of the class. /// [Fact] public void SettingsTest_Equals() @@ -81,7 +81,7 @@ public void SettingsTest_Equals() } /// - /// Tests the GetHashCode method of the class. + /// Tests the GetHashCode method of the class. /// [Fact] public void SettingsTest_Hash() @@ -96,10 +96,9 @@ public void SettingsTest_Hash() Assert.True(h1.Equals(h2)); Assert.False(h1.Equals(h3)); - } - + #endregion #endregion -} +} \ No newline at end of file diff --git a/src/jjm.one.RabbitMqClientWrapper.Tests/types/exceptions/NoChannelExceptionTests.cs b/src/jjm.one.RabbitMqClientWrapper.Tests/types/exceptions/NoChannelExceptionTests.cs index 80bc112..16e3c53 100644 --- a/src/jjm.one.RabbitMqClientWrapper.Tests/types/exceptions/NoChannelExceptionTests.cs +++ b/src/jjm.one.RabbitMqClientWrapper.Tests/types/exceptions/NoChannelExceptionTests.cs @@ -1,4 +1,3 @@ -using FluentAssertions; using jjm.one.RabbitMqClientWrapper.main.core; using jjm.one.RabbitMqClientWrapper.types.exceptions; using RabbitMQ.Client; @@ -6,7 +5,7 @@ namespace jjm.one.RabbitMqClientWrapper.Tests.types.exceptions; /// -/// This class contains the unit tests for the class. +/// This class contains the unit tests for the class. /// public class NoChannelExceptionTests { @@ -15,14 +14,14 @@ public class NoChannelExceptionTests #region ctor tests /// - /// Tests the default constructor of the class. + /// Tests the default constructor of the class. /// [Fact] public void NoChannelExceptionTest_DefaultCtorTest() { // arrange + act var e = new NoChannelException(); - + // assert e.Message.Should().Be($"The {nameof(IModel)} is null! " + $"Maybe the {nameof(RmqcCore)} was not initialized properly."); diff --git a/src/jjm.one.RabbitMqClientWrapper.Tests/types/exceptions/NoConnectionExceptionTests.cs b/src/jjm.one.RabbitMqClientWrapper.Tests/types/exceptions/NoConnectionExceptionTests.cs index 96a4b87..6725761 100644 --- a/src/jjm.one.RabbitMqClientWrapper.Tests/types/exceptions/NoConnectionExceptionTests.cs +++ b/src/jjm.one.RabbitMqClientWrapper.Tests/types/exceptions/NoConnectionExceptionTests.cs @@ -1,4 +1,3 @@ -using FluentAssertions; using jjm.one.RabbitMqClientWrapper.main.core; using jjm.one.RabbitMqClientWrapper.types.exceptions; using RabbitMQ.Client; @@ -6,28 +5,28 @@ namespace jjm.one.RabbitMqClientWrapper.Tests.types.exceptions; /// -/// This class contains the unit tests for the class. +/// This class contains the unit tests for the class. /// public class NoConnectionExceptionTests { #region tests #region ctor tests - + /// - /// Tests the default constructor of the class. + /// Tests the default constructor of the class. /// [Fact] public void NoConnectionExceptionTest_DefaultCtorTest() { // arrange + act var e = new NoConnectionException(); - + // assert e.Message.Should().Be($"The {nameof(IConnection)} is null! " + $"Maybe the {nameof(RmqcCore)} was not initialized properly."); } - + #endregion #endregion diff --git a/src/jjm.one.RabbitMqClientWrapper.Tests/types/exceptions/NoConnectionFactoryExceptionTests.cs b/src/jjm.one.RabbitMqClientWrapper.Tests/types/exceptions/NoConnectionFactoryExceptionTests.cs index d0978ae..98b93ff 100644 --- a/src/jjm.one.RabbitMqClientWrapper.Tests/types/exceptions/NoConnectionFactoryExceptionTests.cs +++ b/src/jjm.one.RabbitMqClientWrapper.Tests/types/exceptions/NoConnectionFactoryExceptionTests.cs @@ -1,4 +1,3 @@ -using FluentAssertions; using jjm.one.RabbitMqClientWrapper.main.core; using jjm.one.RabbitMqClientWrapper.types.exceptions; using RabbitMQ.Client; @@ -6,28 +5,28 @@ namespace jjm.one.RabbitMqClientWrapper.Tests.types.exceptions; /// -/// This class contains the unit tests for the class. +/// This class contains the unit tests for the class. /// public class NoConnectionFactoryExceptionTests { #region tests #region ctor tests - + /// - /// Tests the default constructor of the class. + /// Tests the default constructor of the class. /// [Fact] public void NoConnectionFactoryExceptionTest_DefaultCtorTest() { // arrange + act var e = new NoConnectionFactoryException(); - + // assert e.Message.Should().Be($"The {nameof(IConnectionFactory)} is null! " + $"Maybe the {nameof(RmqcCore)} was not initialized properly."); } - + #endregion #endregion diff --git a/src/jjm.one.RabbitMqClientWrapper.Tests/types/exceptions/UnInitializedClientExceptionTests.cs b/src/jjm.one.RabbitMqClientWrapper.Tests/types/exceptions/UnInitializedClientExceptionTests.cs index a421d7f..abe5ce2 100644 --- a/src/jjm.one.RabbitMqClientWrapper.Tests/types/exceptions/UnInitializedClientExceptionTests.cs +++ b/src/jjm.one.RabbitMqClientWrapper.Tests/types/exceptions/UnInitializedClientExceptionTests.cs @@ -1,10 +1,9 @@ -using FluentAssertions; using jjm.one.RabbitMqClientWrapper.types.exceptions; namespace jjm.one.RabbitMqClientWrapper.Tests.types.exceptions; /// -/// This class contains the unit tests for the class. +/// This class contains the unit tests for the class. /// public class UnInitializedClientExceptionTests { @@ -13,27 +12,27 @@ public class UnInitializedClientExceptionTests #region ctor tests /// - /// Tests the default constructor of the class. + /// Tests the default constructor of the class. /// [Fact] public void UnInitializedClientExceptionTest_DefaultCtorTest() { // arrange + act var e = new UnInitializedClientException(); - + // assert e.Message.Should().Be("Client must be initialized and connected to perform this operation!"); } - + /// - /// Tests the constructor of the class. + /// Tests the constructor of the class. /// [Fact] public void UnInitializedClientExceptionTest_CtorTest() { // arrange + act var e = new UnInitializedClientException("TEST"); - + // assert e.Message.Should().Be("Client must be initialized and connected to perform the TEST operation!"); } diff --git a/src/jjm.one.RabbitMqClientWrapper.Utils/DataRepresentation/DataTableTools.cs b/src/jjm.one.RabbitMqClientWrapper.Utils/DataRepresentation/DataTableTools.cs index 739d6a1..1b77b18 100644 --- a/src/jjm.one.RabbitMqClientWrapper.Utils/DataRepresentation/DataTableTools.cs +++ b/src/jjm.one.RabbitMqClientWrapper.Utils/DataRepresentation/DataTableTools.cs @@ -1,21 +1,82 @@ using System; using System.Collections.Generic; using System.Data; -using RabbitMQ.Client; using System.Text; using jjm.one.RabbitMqClientWrapper.types; +using RabbitMQ.Client; namespace jjm.one.RabbitMqClientWrapper.Utils.DataRepresentation; /// -/// This static class contains functions and extensions to convert a and it's elements to a and wise versa. +/// This static class contains functions and extensions to convert a and it's elements to a +/// and wise versa. /// public static class DataTableTools { + #region public functions + + /// + /// This extension converts a into a . + /// + /// + /// + /// + /// + /// + public static DataTablesToMessageConversionStatus DataTablesToMessage(ref RmqcMessage? message, + DataTable metadata, DataTable basicProperties, DataTable headers) + { + var res = DataTablesToMessageConversionStatus.None; + + // check input -------------------------------------------------------- + + if (message is null) + { + res |= DataTablesToMessageConversionStatus.OgMsgNull; + message = new RmqcMessage(); + } + + if (message.BasicProperties is null) res |= DataTablesToMessageConversionStatus.OgBasicPropNull; + + if (message.Headers is null) + { + res |= DataTablesToMessageConversionStatus.OgHeadersNull; + message.Headers = new Dictionary(); + } + + // check input end ---------------------------------------------------- + + // fill data ---------------------------------------------------------- + + if (!UpdateMetaDataInMessage(ref message, metadata)) + { + res |= DataTablesToMessageConversionStatus.Error; + res |= DataTablesToMessageConversionStatus.MissFormattedMetaData; + } + + if (message.BasicProperties is not null && !UpdateBasicPropsInMessage(ref message, basicProperties)) + { + res |= DataTablesToMessageConversionStatus.Warning; + res |= DataTablesToMessageConversionStatus.MissFormattedBasicProps; + } + + if (!UpdateHeadersInMessage(ref message, headers)) + { + res |= DataTablesToMessageConversionStatus.Error; + res |= DataTablesToMessageConversionStatus.MissFormattedHeaders; + } + + // fill data end ------------------------------------------------------ + + return res; + } + + #endregion + #region public extension functions /// - /// This extension converts a into a . + /// This extension converts a into a . /// /// /// @@ -35,17 +96,13 @@ public static DataTable ToDataTable(this RmqcMessage message) var ogType = type; if (type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>)) - { type = Nullable.GetUnderlyingType(type); - } if (type != typeof(bool) && type != typeof(ulong) && type != typeof(string) && type != typeof(DateTime)) - { continue; - } var newRow = res.NewRow(); newRow["Property"] = propertyInfo.Name; @@ -59,7 +116,7 @@ public static DataTable ToDataTable(this RmqcMessage message) } /// - /// This extension converts a into a . + /// This extension converts a into a . /// /// /// @@ -79,14 +136,9 @@ public static DataTable ToDataTable(this IBasicProperties basicProperties) var ogType = type; if (type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>)) - { type = Nullable.GetUnderlyingType(type); - } - if (type == typeof(IDictionary)) - { - continue; - } + if (type == typeof(IDictionary)) continue; var newRow = res.NewRow(); newRow["Property"] = propertyInfo.Name; @@ -100,7 +152,7 @@ public static DataTable ToDataTable(this IBasicProperties basicProperties) } /// - /// This extension converts a into a . + /// This extension converts a into a . /// /// /// @@ -145,122 +197,68 @@ public static DataTable ToDataTable(this IDictionary dict) #endregion - #region public functions - - /// - /// This extension converts a into a . - /// - /// - /// - /// - /// - /// - public static DataTablesToMessageConversionStatus DataTablesToMessage(ref RmqcMessage? message, - DataTable metadata, DataTable basicProperties, DataTable headers) - { - var res = DataTablesToMessageConversionStatus.None; - - // check input -------------------------------------------------------- - - if (message is null) - { - res |= DataTablesToMessageConversionStatus.OgMsgNull; - message = new RmqcMessage(); - } - - if (message.BasicProperties is null) - { - res |= DataTablesToMessageConversionStatus.OgBasicPropNull; - } - - if (message.Headers is null) - { - res |= DataTablesToMessageConversionStatus.OgHeadersNull; - message.Headers = new Dictionary(); - } - - // check input end ---------------------------------------------------- - - // fill data ---------------------------------------------------------- - - if (!UpdateMetaDataInMessage(ref message, metadata)) - { - res |= DataTablesToMessageConversionStatus.Error; - res |= DataTablesToMessageConversionStatus.MissFormattedMetaData; - } - - if (message.BasicProperties is not null && !UpdateBasicPropsInMessage(ref message, basicProperties)) - { - res |= DataTablesToMessageConversionStatus.Warning; - res |= DataTablesToMessageConversionStatus.MissFormattedBasicProps; - } - - if (!UpdateHeadersInMessage(ref message, headers)) - { - res |= DataTablesToMessageConversionStatus.Error; - res |= DataTablesToMessageConversionStatus.MissFormattedHeaders; - } - - // fill data end ------------------------------------------------------ - - return res; - } - - #endregion - #region public enunms /// - /// This enum represents the conversion status when converting to . + /// This enum represents the conversion status when converting to . /// [Flags] public enum DataTablesToMessageConversionStatus : ushort { /// - /// Status = None + /// Status = None /// None = 0, + /// - /// Status = ok + /// Status = ok /// Ok = 1 << 0, + /// - /// Status = origin message is null + /// Status = origin message is null /// OgMsgNull = 1 << 1, + /// - /// Status = origin basic properties are null + /// Status = origin basic properties are null /// OgBasicPropNull = 1 << 2, + /// - /// Status = origin headers are null + /// Status = origin headers are null /// OgHeadersNull = 1 << 3, + /// - /// Status = error + /// Status = error /// Error = 1 << 4, + /// - /// status = warning + /// status = warning /// Warning = 1 << 5, + /// - /// Status = miss formatted meta data + /// Status = miss formatted meta data /// MissFormattedMetaData = 1 << 6, + /// - /// Status = miss formatted basic properties + /// Status = miss formatted basic properties /// MissFormattedBasicProps = 1 << 7, + /// - /// Status = miss formatted headers + /// Status = miss formatted headers /// - MissFormattedHeaders = 1 << 8, - + MissFormattedHeaders = 1 << 8 } /// - /// This function checks whether the conversion failed or not based on the . + /// This function checks whether the conversion failed or not based on the + /// . /// /// /// @@ -283,9 +281,7 @@ private static bool UpdateMetaDataInMessage(ref RmqcMessage message, DataTable m !metadata.Columns.Contains("Value") || !metadata.Columns.Contains("ReadOnly") || !metadata.Columns.Contains("Type")) - { return false; - } var propertyInfos = message.GetType().GetProperties(); foreach (var propertyInfo in propertyInfos) @@ -293,20 +289,15 @@ private static bool UpdateMetaDataInMessage(ref RmqcMessage message, DataTable m var type = propertyInfo.PropertyType; if (type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>)) - { type = Nullable.GetUnderlyingType(type); - } if (type != typeof(bool) && type != typeof(ulong) && type != typeof(string) && type != typeof(DateTime)) - { continue; - } foreach (DataRow row in metadata.Rows) - { if (row["Property"].Equals(propertyInfo.Name)) { if (propertyInfo.CanWrite) @@ -324,13 +315,14 @@ private static bool UpdateMetaDataInMessage(ref RmqcMessage message, DataTable m if (res) propertyInfo.SetValue(message, value); } } - else { + else + { propertyInfo.SetValue(message, row["Value"] is DBNull ? null : row["Value"]); } } + break; } - } } return true; @@ -343,34 +335,24 @@ private static bool UpdateBasicPropsInMessage(ref RmqcMessage message, DataTable !basicProperties.Columns.Contains("Value") || !basicProperties.Columns.Contains("ReadOnly") || !basicProperties.Columns.Contains("Type")) - { return false; - } var propertyInfos = message.BasicProperties?.GetType().GetProperties(); - if (propertyInfos is null) - { - return false; - } + if (propertyInfos is null) return false; foreach (var propertyInfo in propertyInfos) { var type = propertyInfo.PropertyType; if (type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>)) - { type = Nullable.GetUnderlyingType(type); - } if (type != typeof(bool) && type != typeof(ushort) && type != typeof(string) && type != typeof(AmqpTimestamp)) - { continue; - } foreach (DataRow row in basicProperties.Rows) - { if (row["Property"].Equals(propertyInfo.Name)) { if (propertyInfo.CanWrite) @@ -390,12 +372,13 @@ private static bool UpdateBasicPropsInMessage(ref RmqcMessage message, DataTable } else { - propertyInfo.SetValue(message.BasicProperties, row["Value"] is DBNull ? null : row["Value"]); + propertyInfo.SetValue(message.BasicProperties, + row["Value"] is DBNull ? null : row["Value"]); } } + break; } - } } return true; @@ -406,23 +389,15 @@ private static bool UpdateHeadersInMessage(ref RmqcMessage message, DataTable he // data table check if (!headers.Columns.Contains("Property") || !headers.Columns.Contains("Value") || - !headers.Columns.Contains("Type") ) - { + !headers.Columns.Contains("Type")) return false; - } - if (message.Headers is null) - { - return false; - } + if (message.Headers is null) return false; foreach (DataRow row in headers.Rows) { var p = row["Property"].ToString(); var v = row["Value"]; - if (string.IsNullOrEmpty(p) || v is DBNull) - { - continue; - } + if (string.IsNullOrEmpty(p) || v is DBNull) continue; message.Headers[p] = v; } diff --git a/src/jjm.one.RabbitMqClientWrapper.Utils/jjm.one.RabbitMqClientWrapper.Utils.csproj b/src/jjm.one.RabbitMqClientWrapper.Utils/jjm.one.RabbitMqClientWrapper.Utils.csproj index 1f4fd97..e5cc45d 100644 --- a/src/jjm.one.RabbitMqClientWrapper.Utils/jjm.one.RabbitMqClientWrapper.Utils.csproj +++ b/src/jjm.one.RabbitMqClientWrapper.Utils/jjm.one.RabbitMqClientWrapper.Utils.csproj @@ -5,7 +5,7 @@ disable enable 1.0.0-alpha.7 - Jonas Merkle [JJM] + Jonas Merkle [JJM] © by Jonas Merkle [JJM], 2024. jjm.one.RabbitMqClientWrapper.Utils jjm.one.RabbitMqClientWrapper.Utils @@ -25,13 +25,11 @@ latestmajor - latestmajor - - + True @@ -44,7 +42,7 @@ - + diff --git a/src/jjm.one.RabbitMqClientWrapper/di/RmqcWrapperDi.cs b/src/jjm.one.RabbitMqClientWrapper/di/RmqcWrapperDi.cs index b58a37f..d4ba457 100644 --- a/src/jjm.one.RabbitMqClientWrapper/di/RmqcWrapperDi.cs +++ b/src/jjm.one.RabbitMqClientWrapper/di/RmqcWrapperDi.cs @@ -6,12 +6,12 @@ namespace jjm.one.RabbitMqClientWrapper.di; /// -/// This class contains function for dependency injection of the class. +/// This class contains function for dependency injection of the class. /// public static class RmqcWrapperDi { /// - /// Adds all dependencies ot the class to a . + /// Adds all dependencies ot the class to a . /// /// /// @@ -23,5 +23,4 @@ public static IServiceCollection AddRmqcWrapper(this IServiceCollection services return services; } -} - +} \ No newline at end of file diff --git a/src/jjm.one.RabbitMqClientWrapper/di/core/RmqcCoreDi.cs b/src/jjm.one.RabbitMqClientWrapper/di/core/RmqcCoreDi.cs index 384955e..2c89b81 100644 --- a/src/jjm.one.RabbitMqClientWrapper/di/core/RmqcCoreDi.cs +++ b/src/jjm.one.RabbitMqClientWrapper/di/core/RmqcCoreDi.cs @@ -5,22 +5,21 @@ namespace jjm.one.RabbitMqClientWrapper.di.core; /// -/// This class contains function for dependency injection of the class. +/// This class contains function for dependency injection of the class. /// internal static class RmqcCoreDi { - /// - /// Adds all dependencies ot the class to a . - /// - /// - /// - /// + /// + /// Adds all dependencies ot the class to a . + /// + /// + /// + /// public static IServiceCollection AddRmqcCore(this IServiceCollection services, RmqcSettings settings) - { - services.AddSingleton(settings); - services.AddScoped(sp => ActivatorUtilities.CreateInstance(sp)); - - return services; - } -} + { + services.AddSingleton(settings); + services.AddScoped(sp => ActivatorUtilities.CreateInstance(sp)); + return services; + } +} \ No newline at end of file diff --git a/src/jjm.one.RabbitMqClientWrapper/jjm.one.RabbitMqClientWrapper.csproj b/src/jjm.one.RabbitMqClientWrapper/jjm.one.RabbitMqClientWrapper.csproj index 868eb11..bd1bdf6 100644 --- a/src/jjm.one.RabbitMqClientWrapper/jjm.one.RabbitMqClientWrapper.csproj +++ b/src/jjm.one.RabbitMqClientWrapper/jjm.one.RabbitMqClientWrapper.csproj @@ -1,56 +1,54 @@ - - net6.0;net7.0;net8.0;netstandard2.0;netstandard2.1 - disable - enable - 1.0.0-alpha.7 - Jonas Merkle [JJM] - © by Jonas Merkle [JJM], 2024. - jjm.one.RabbitMqClientWrapper - jjm.one.RabbitMqClientWrapper - jjm.one.RabbitMqClientWrapper - A csharp wrapper for a RabbitMQ client. - utility, helper, wrapper, rabbitmq, client, csharp - https://github.com/jjm-one/jjm.one.RabbitMqClientWrapper - git - https://github.com/jjm-one/jjm.one.RabbitMqClientWrapper.git - README.md - LICENSE - True - True - True - jjm.one.RabbitMqClientWrapper.SignKey.snk - + + net6.0;net7.0;net8.0;netstandard2.0;netstandard2.1 + disable + enable + 1.0.0-alpha.7 + Jonas Merkle [JJM] + © by Jonas Merkle [JJM], 2024. + jjm.one.RabbitMqClientWrapper + jjm.one.RabbitMqClientWrapper + jjm.one.RabbitMqClientWrapper + A csharp wrapper for a RabbitMQ client. + utility, helper, wrapper, rabbitmq, client, csharp + https://github.com/jjm-one/jjm.one.RabbitMqClientWrapper + git + https://github.com/jjm-one/jjm.one.RabbitMqClientWrapper.git + README.md + LICENSE + True + True + True + jjm.one.RabbitMqClientWrapper.SignKey.snk + - - - - - + + + + + - - latestmajor - - - - latestmajor - - - - - - True - \ - - - True - \ - - + + latestmajor + + + latestmajor + - - - - + + + True + \ + + + True + \ + + + + + + + diff --git a/src/jjm.one.RabbitMqClientWrapper/main/IRmqcWrapper.cs b/src/jjm.one.RabbitMqClientWrapper/main/IRmqcWrapper.cs index 6bffb47..5a586b1 100644 --- a/src/jjm.one.RabbitMqClientWrapper/main/IRmqcWrapper.cs +++ b/src/jjm.one.RabbitMqClientWrapper/main/IRmqcWrapper.cs @@ -6,89 +6,89 @@ namespace jjm.one.RabbitMqClientWrapper.main; /// -/// This interface defines the core and additional functionality to connect and communicate with a RabbitMQ server. +/// This interface defines the core and additional functionality to connect and communicate with a RabbitMQ server. /// public interface IRmqcWrapper : IRmqcCore { + #region public events + + /// + /// This events gets invoked when the re-connect function finishes. + /// + public event EventHandler ReConnectCompleted; + + #endregion + #region public methods /// - /// Connect to the RabbitMQ server. + /// Connect to the RabbitMQ server. /// - /// on success, else . + /// on success, else . public bool Connect(); - + /// - /// Disconnect from the RabbitMQ server. + /// Disconnect from the RabbitMQ server. /// - /// on success, else . + /// on success, else . public bool Disconnect(); /// - /// Disconnect and connects form the RabbitMQ server. + /// Disconnect and connects form the RabbitMQ server. /// - /// on success, else . + /// on success, else . public bool ReConnect(); - + /// - /// Disconnect and connects form the RabbitMQ server. + /// Disconnect and connects form the RabbitMQ server. /// /// - /// on success, else . + /// on success, else . public bool ReConnect(out Exception? exception); /// - /// Write a to the RabbitMQ server + /// Write a to the RabbitMQ server /// /// - /// on success, else . + /// on success, else . public bool WriteMsg(ref RmqcMessage message); /// - /// Read a to the RabbitMQ server. + /// Read a to the RabbitMQ server. /// /// /// - /// on success, else . + /// on success, else . public bool ReadMsg(out RmqcMessage? message, bool autoAck); /// - /// Ack a received . + /// Ack a received . /// /// - /// on success, else . + /// on success, else . public bool AckMsg(ref RmqcMessage message); /// - /// NAck a received . + /// NAck a received . /// /// /// - /// on success, else . + /// on success, else . public bool NAckMsg(ref RmqcMessage message, bool requeue); /// - /// Wait until the server confirms the written . + /// Wait until the server confirms the written . /// /// - /// on success, else . + /// on success, else . public bool WaitForWriteConfirm(TimeSpan timeout); /// - /// Get the amount of queued in the RabbitMQ server queue which are ready get read. + /// Get the amount of queued in the RabbitMQ server queue which are ready get read. /// /// - /// on success, else . + /// on success, else . public bool QueuedMsgs(out uint? amount); #endregion - - #region public events - - /// - /// This events gets invoked when the re-connect function finishes. - /// - public event EventHandler ReConnectCompleted; - - #endregion -} +} \ No newline at end of file diff --git a/src/jjm.one.RabbitMqClientWrapper/main/RmqcWrapper.cs b/src/jjm.one.RabbitMqClientWrapper/main/RmqcWrapper.cs index 6e937fc..3666d51 100644 --- a/src/jjm.one.RabbitMqClientWrapper/main/RmqcWrapper.cs +++ b/src/jjm.one.RabbitMqClientWrapper/main/RmqcWrapper.cs @@ -11,10 +11,27 @@ namespace jjm.one.RabbitMqClientWrapper.main; /// -/// This class implements the interface for a RabbitMQ server. +/// This class implements the interface for a RabbitMQ server. /// public class RmqcWrapper : IRmqcWrapper { + #region private event invokation + + /// + /// This method invokes the envent handlers. + /// + /// + private void OnReConnectCompleted(ReConnectCompletedEventArgs e) + { + // log fct call + _logger?.LogFctCall(GetType(), MethodBase.GetCurrentMethod(), LogLevel.Trace); + + // invoke event handlers + ReConnectCompleted?.Invoke(this, e); + } + + #endregion + #region private members private readonly IRmqcCore _core; @@ -25,9 +42,9 @@ public class RmqcWrapper : IRmqcWrapper #region public members /// - /// This object contains the settings for the RabbitMQ client. - /// Note: - /// Changing the object of a connected client will result in the disconnection from the server. + /// This object contains the settings for the RabbitMQ client. + /// Note: + /// Changing the object of a connected client will result in the disconnection from the server. /// public RmqcSettings Settings { @@ -64,7 +81,7 @@ public bool Connected #region ctors /// - /// A parameterized constructor of the class. + /// A parameterized constructor of the class. /// /// /// @@ -90,11 +107,11 @@ public RmqcWrapper(IRmqcCore core, ILogger? logger) } /// - /// A parameterized constructor of the class. + /// A parameterized constructor of the class. /// /// /// - public RmqcWrapper(RmqcSettings settings, + public RmqcWrapper(RmqcSettings settings, ILogger? logger = null) { _core = new RmqcCore(settings); @@ -110,7 +127,7 @@ public RmqcWrapper(RmqcSettings settings, _core.QueuedMsgsCompleted += OnQueuedMsgsCompleted; _core.ConnectionStateChanged += OnConnectionStateChanged; _core.ErrorOccurred += OnErrorOccurred; - + // log fct call _logger?.LogFctCall(GetType(), MethodBase.GetCurrentMethod(), LogLevel.Trace); } @@ -130,16 +147,16 @@ public RmqcWrapper(RmqcSettings settings, /// public event EventHandler? WriteMsgCompleted; - + /// public event EventHandler? ReadMsgCompleted; - + /// public event EventHandler? AckMsgCompleted; - + /// public event EventHandler? NAckMsgComplete; - + /// public event EventHandler? QueuedMsgsCompleted; @@ -150,7 +167,7 @@ public RmqcWrapper(RmqcSettings settings, public event EventHandler? ErrorOccurred; #endregion - + #region public methods /// @@ -198,7 +215,7 @@ public bool Disconnect() return Disconnect(out _); } - + /// public bool Disconnect(out Exception? exception) { @@ -309,7 +326,7 @@ public bool AckMsg(ref RmqcMessage message, out Exception? exception) { // log fct call _logger?.LogFctCall(GetType(), MethodBase.GetCurrentMethod(), LogLevel.Trace); - + // call the core functions return _core.AckMsg(ref message, out exception); } @@ -319,7 +336,7 @@ public bool NAckMsg(ref RmqcMessage message, bool requeue) { // log fct call _logger?.LogFctCall(GetType(), MethodBase.GetCurrentMethod(), LogLevel.Trace); - + return NackMsg(ref message, requeue, out _); } @@ -376,7 +393,7 @@ public bool QueuedMsgs(out uint? amount, out Exception? exception) #region private event callbacks /// - /// This method invokes the envent handlers. + /// This method invokes the envent handlers. /// /// /// @@ -390,7 +407,7 @@ private void OnConnectCompleted(object? o, ConnectCompletedEventArgs e) } /// - /// This method invokes the envent handlers. + /// This method invokes the envent handlers. /// /// /// @@ -404,7 +421,7 @@ private void OnDisconnectCompleted(object? o, DisconnectCompletedEventArgs e) } /// - /// This method invokes the envent handlers. + /// This method invokes the envent handlers. /// /// /// @@ -418,7 +435,7 @@ private void OnWriteMsgCompleted(object? o, WriteMsgCompletedEventArgs e) } /// - /// This method invokes the envent handlers. + /// This method invokes the envent handlers. /// /// /// @@ -432,7 +449,7 @@ private void OnReadMsgCompleted(object? o, ReadMsgCompletedEventArgs e) } /// - /// This method invokes the envent handlers. + /// This method invokes the envent handlers. /// /// /// @@ -446,7 +463,7 @@ private void OnAckMsgCompleted(object? o, AckMsgCompletedEventArgs e) } /// - /// This method invokes the envent handlers. + /// This method invokes the envent handlers. /// /// /// @@ -460,7 +477,7 @@ private void OnNAckMsgComplete(object? o, NackMsgCompletedEventArgs e) } /// - /// This method invokes the envent handlers. + /// This method invokes the envent handlers. /// /// /// @@ -474,7 +491,7 @@ private void OnQueuedMsgsCompleted(object? o, QueuedMsgsCompletedEventArgs e) } /// - /// This method invokes the envent handlers. + /// This method invokes the envent handlers. /// /// /// @@ -488,7 +505,7 @@ private void OnConnectionStateChanged(object? o, ConnectionStatusChangedEventArg } /// - /// This method invokes the envent handlers. + /// This method invokes the envent handlers. /// /// /// @@ -502,21 +519,4 @@ private void OnErrorOccurred(object? o, ErrorOccurredEventArgs e) } #endregion - - #region private event invokation - - /// - /// This method invokes the envent handlers. - /// - /// - private void OnReConnectCompleted(ReConnectCompletedEventArgs e) - { - // log fct call - _logger?.LogFctCall(GetType(), MethodBase.GetCurrentMethod(), LogLevel.Trace); - - // invoke event handlers - ReConnectCompleted?.Invoke(this, e); - } - - #endregion -} +} \ No newline at end of file diff --git a/src/jjm.one.RabbitMqClientWrapper/main/core/IRmqcCore.cs b/src/jjm.one.RabbitMqClientWrapper/main/core/IRmqcCore.cs index b1b2c9c..1e0ec61 100644 --- a/src/jjm.one.RabbitMqClientWrapper/main/core/IRmqcCore.cs +++ b/src/jjm.one.RabbitMqClientWrapper/main/core/IRmqcCore.cs @@ -5,19 +5,19 @@ namespace jjm.one.RabbitMqClientWrapper.main.core; /// -/// This interface defines the core functionality to connect and communicate with a RabbitMQ server. +/// This interface defines the core functionality to connect and communicate with a RabbitMQ server. /// public interface IRmqcCore { #region public members /// - /// This object contains the settings for the RabbitMQ client. + /// This object contains the settings for the RabbitMQ client. /// public RmqcSettings Settings { get; set; } - + /// - /// This flag indicates whether the client is connected the the RabbitMQ server or not. + /// This flag indicates whether the client is connected the the RabbitMQ server or not. /// public bool Connected { get; } @@ -26,77 +26,77 @@ public interface IRmqcCore #region public methods /// - /// Init the connection to the RabbitMQ server. + /// Init the connection to the RabbitMQ server. /// public void Init(); - + /// - /// De-init the connection to the RabbitMQ server. + /// De-init the connection to the RabbitMQ server. /// public void DeInit(); /// - /// Connect to the RabbitMQ server. + /// Connect to the RabbitMQ server. /// /// - /// on success, else . + /// on success, else . public bool Connect(out Exception? exception); /// - /// Disconnect form the RabbitMQ server. + /// Disconnect form the RabbitMQ server. /// /// - /// on success, else . + /// on success, else . public bool Disconnect(out Exception? exception); /// - /// Write a to the RabbitMQ server + /// Write a to the RabbitMQ server /// /// /// - /// on success, else . + /// on success, else . public bool WriteMsg(ref RmqcMessage message, out Exception? exception); - + /// - /// Read a to the RabbitMQ server. + /// Read a to the RabbitMQ server. /// /// /// /// - /// on success, else . + /// on success, else . public bool ReadMsg(out RmqcMessage? message, bool autoAck, out Exception? exception); /// - /// Ack a received . + /// Ack a received . /// /// /// - /// on success, else . + /// on success, else . public bool AckMsg(ref RmqcMessage message, out Exception? exception); - + /// - /// Nack a received . + /// Nack a received . /// /// /// /// - /// on success, else . + /// on success, else . public bool NackMsg(ref RmqcMessage message, bool requeue, out Exception? exception); /// - /// Wait until the server confirms the written . + /// Wait until the server confirms the written . /// /// /// - /// on success, else . + /// on success, else . public bool WaitForWriteConfirm(TimeSpan timeout, out Exception? exception); /// - /// Get the amount of stored in the RabbitMQ server queue which are ready get read. + /// Get the amount of stored in the RabbitMQ server queue which are ready get read. /// /// /// - /// on success, else . + /// on success, else . public bool QueuedMsgs(out uint? amount, out Exception? exception); #endregion @@ -104,47 +104,47 @@ public interface IRmqcCore #region public events /// - /// This events gets invoked when the connect function finishes. + /// This events gets invoked when the connect function finishes. /// public event EventHandler ConnectCompleted; /// - /// This events gets invoked when the disconnect function finishes. + /// This events gets invoked when the disconnect function finishes. /// public event EventHandler DisconnectCompleted; /// - /// This events gets invoked when the write msg function finishes. + /// This events gets invoked when the write msg function finishes. /// public event EventHandler WriteMsgCompleted; /// - /// This events gets invoked when the read msg function finishes. + /// This events gets invoked when the read msg function finishes. /// public event EventHandler ReadMsgCompleted; /// - /// This events gets invoked when the ack msg function finishes. + /// This events gets invoked when the ack msg function finishes. /// public event EventHandler AckMsgCompleted; /// - /// This events gets invoked when the nack msg function finishes. + /// This events gets invoked when the nack msg function finishes. /// public event EventHandler NAckMsgComplete; /// - /// This events gets invoked when the queued msg's function finishes. + /// This events gets invoked when the queued msg's function finishes. /// public event EventHandler QueuedMsgsCompleted; /// - /// This events gets invoked when the connection status changes. + /// This events gets invoked when the connection status changes. /// public event EventHandler ConnectionStateChanged; /// - /// This events gets invoked when an error occurred. + /// This events gets invoked when an error occurred. /// public event EventHandler ErrorOccurred; diff --git a/src/jjm.one.RabbitMqClientWrapper/main/core/RmqcCore.cs b/src/jjm.one.RabbitMqClientWrapper/main/core/RmqcCore.cs index 6b744d2..2f01b7b 100644 --- a/src/jjm.one.RabbitMqClientWrapper/main/core/RmqcCore.cs +++ b/src/jjm.one.RabbitMqClientWrapper/main/core/RmqcCore.cs @@ -12,7 +12,7 @@ namespace jjm.one.RabbitMqClientWrapper.main.core; /// -/// This class implements the interface for a RabbitMQ server. +/// This class implements the interface for a RabbitMQ server. /// internal class RmqcCore : IRmqcCore { @@ -31,9 +31,9 @@ internal class RmqcCore : IRmqcCore #region public members /// - /// This object contains the settings for the RabbitMQ client. - /// Note: - /// Changing the object of a connected client will result in the disconnection from the server. + /// This object contains the settings for the RabbitMQ client. + /// Note: + /// Changing the object of a connected client will result in the disconnection from the server. /// public RmqcSettings Settings { @@ -50,11 +50,8 @@ public RmqcSettings Settings _logger?.LogFctCall(GetType(), MethodBase.GetCurrentMethod(), LogLevel.Trace); // check im nothing changed - if (_settings.Equals(value)) - { - return; - } - + if (_settings.Equals(value)) return; + // disconnect & re-init the connection Disconnect(out _); _settings = value; @@ -71,10 +68,7 @@ public bool Connected if (_connectionFactory is null) { // update the internal value in necessary - if (_connected) - { - Connected = false; - } + if (_connected) Connected = false; return false; } @@ -83,10 +77,7 @@ public bool Connected if (_connection is null || !_connection.IsOpen) { // update the internal value in necessary - if (_connected) - { - Connected = false; - } + if (_connected) Connected = false; return false; } @@ -95,19 +86,13 @@ public bool Connected if (_channel is null || !_channel.IsOpen) { // update the internal value in necessary - if (_connected) - { - Connected = false; - } + if (_connected) Connected = false; return false; } // update the internal value in necessary - if (!_connected) - { - Connected = true; - } + if (!_connected) Connected = true; // connected! return true; @@ -117,10 +102,8 @@ private set { // check if the new value is equal to the old value if (_connected == value) - { // nothing to do return; - } // set the value _connected = value; @@ -135,7 +118,7 @@ private set #region ctors /// - /// A parameterized constructor of the class. + /// A parameterized constructor of the class. /// /// /// @@ -152,8 +135,8 @@ public RmqcCore(RmqcSettings settings, ILogger? logger = null) } /// - /// A parameterized constructor of the class. - /// For unit-tests only! + /// A parameterized constructor of the class. + /// For unit-tests only! /// /// /// @@ -254,30 +237,21 @@ public bool Connect(out Exception? exception) try { // check connection factory - if (_connectionFactory is null) - { - throw new NoConnectionFactoryException(); - } + if (_connectionFactory is null) throw new NoConnectionFactoryException(); // create the connection _connection = _connectionFactory.CreateConnection(); // check connection - if (_connection is null) - { - throw new NoConnectionException(); - } + if (_connection is null) throw new NoConnectionException(); // create the channel _channel = _connection.CreateModel(); // check channel - if (_channel is null) - { - throw new NoChannelException(); - } + if (_channel is null) throw new NoChannelException(); } - catch(Exception exc) + catch (Exception exc) { // log exception _logger?.LogExcInFctCall(exc, GetType(), MethodBase.GetCurrentMethod(), exc.Message, LogLevel.Warning); @@ -300,7 +274,8 @@ public bool Connect(out Exception? exception) sw.Stop(); // invoke associated event - OnConnectCompleted(new ConnectCompletedEventArgs(res, exception, TimeSpan.FromMilliseconds(sw.ElapsedMilliseconds))); + OnConnectCompleted(new ConnectCompletedEventArgs(res, exception, + TimeSpan.FromMilliseconds(sw.ElapsedMilliseconds))); // return the result return res; @@ -325,10 +300,7 @@ public bool Disconnect(out Exception? exception) // disconnect channel if (_channel is not null) { - if (_channel.IsOpen) - { - _channel.Close(); - } + if (_channel.IsOpen) _channel.Close(); _channel.Dispose(); _channel = null; @@ -337,10 +309,7 @@ public bool Disconnect(out Exception? exception) // disconnect connection if (_connection is not null) { - if (_connection.IsOpen) - { - _connection.Close(); - } + if (_connection.IsOpen) _connection.Close(); _connection.Dispose(); _connection = null; @@ -366,7 +335,8 @@ public bool Disconnect(out Exception? exception) sw.Stop(); // invoke associated event - OnDisconnectCompleted(new DisconnectCompletedEventArgs(res, exception, TimeSpan.FromMilliseconds(sw.ElapsedMilliseconds))); + OnDisconnectCompleted(new DisconnectCompletedEventArgs(res, exception, + TimeSpan.FromMilliseconds(sw.ElapsedMilliseconds))); // return the result return res; @@ -389,18 +359,12 @@ public bool WriteMsg(ref RmqcMessage message, out Exception? exception) try { // check connection to server - if (!Connected) - { - throw new InvalidOperationException(nameof(WriteMsg)); - } + if (!Connected) throw new InvalidOperationException(nameof(WriteMsg)); // crate basic properties var props = _channel?.CreateBasicProperties(); - if (message.Headers is not null && props is not null) - { - props.Headers = message.Headers; - } - + if (message.Headers is not null && props is not null) props.Headers = message.Headers; + // write message _channel?.BasicPublish(Settings.Exchange, message.RoutingKey, props, message.BodyArray ?? null); message.TimestampWhenSend = DateTime.Now; @@ -422,7 +386,8 @@ public bool WriteMsg(ref RmqcMessage message, out Exception? exception) sw.Stop(); // invoke associated event - OnWriteMsgCompleted(new WriteMsgCompletedEventArgs(res, exception, TimeSpan.FromMilliseconds(sw.ElapsedMilliseconds))); + OnWriteMsgCompleted(new WriteMsgCompletedEventArgs(res, exception, + TimeSpan.FromMilliseconds(sw.ElapsedMilliseconds))); // return the result return res; @@ -446,10 +411,7 @@ public bool ReadMsg(out RmqcMessage? message, bool autoAck, out Exception? excep try { // check connection to server - if (!Connected) - { - throw new InvalidOperationException(nameof(ReadMsg)); - } + if (!Connected) throw new InvalidOperationException(nameof(ReadMsg)); // read message var msg = _channel?.BasicGet(Settings.Queue, autoAck); @@ -466,10 +428,7 @@ public bool ReadMsg(out RmqcMessage? message, bool autoAck, out Exception? excep TimestampWhenReceived = DateTime.Now }; - if (autoAck) - { - message.TimestampWhenAcked = message.TimestampWhenReceived; - } + if (autoAck) message.TimestampWhenAcked = message.TimestampWhenReceived; } } catch (Exception exc) @@ -489,7 +448,8 @@ public bool ReadMsg(out RmqcMessage? message, bool autoAck, out Exception? excep sw.Stop(); // invoke associated event - OnReadMsgCompleted(new ReadMsgCompletedEventArgs(res, exception, TimeSpan.FromMilliseconds(sw.ElapsedMilliseconds), message)); + OnReadMsgCompleted(new ReadMsgCompletedEventArgs(res, exception, + TimeSpan.FromMilliseconds(sw.ElapsedMilliseconds), message)); // return the result return res; @@ -512,10 +472,7 @@ public bool AckMsg(ref RmqcMessage message, out Exception? exception) try { // check connection to server - if (!Connected) - { - throw new InvalidOperationException(nameof(AckMsg)); - } + if (!Connected) throw new InvalidOperationException(nameof(AckMsg)); // send ack _channel?.BasicAck(message.DeliveryTag, false); @@ -538,7 +495,8 @@ public bool AckMsg(ref RmqcMessage message, out Exception? exception) sw.Stop(); // invoke associated event - OnAckMsgCompleted(new AckMsgCompletedEventArgs(res, exception, TimeSpan.FromMilliseconds(sw.ElapsedMilliseconds), message.DeliveryTag)); + OnAckMsgCompleted(new AckMsgCompletedEventArgs(res, exception, + TimeSpan.FromMilliseconds(sw.ElapsedMilliseconds), message.DeliveryTag)); // return the result return res; @@ -561,10 +519,7 @@ public bool NackMsg(ref RmqcMessage message, bool requeue, out Exception? except try { // check connection to server - if (!Connected) - { - throw new InvalidOperationException(nameof(NackMsg)); - } + if (!Connected) throw new InvalidOperationException(nameof(NackMsg)); // send nack _channel?.BasicNack(message.DeliveryTag, false, requeue); @@ -588,7 +543,8 @@ public bool NackMsg(ref RmqcMessage message, bool requeue, out Exception? except sw.Stop(); // invoke associated event - OnNackMsgComplete(new NackMsgCompletedEventArgs(res, exception, TimeSpan.FromMilliseconds(sw.ElapsedMilliseconds), message.DeliveryTag)); + OnNackMsgComplete(new NackMsgCompletedEventArgs(res, exception, + TimeSpan.FromMilliseconds(sw.ElapsedMilliseconds), message.DeliveryTag)); // return the result return res; @@ -611,10 +567,7 @@ public bool WaitForWriteConfirm(TimeSpan timeout, out Exception? exception) try { // check connection to server - if (!Connected) - { - throw new InvalidOperationException(nameof(WaitForWriteConfirm)); - } + if (!Connected) throw new InvalidOperationException(nameof(WaitForWriteConfirm)); // send nack res &= _channel?.WaitForConfirms(timeout) ?? false; @@ -660,10 +613,7 @@ public bool QueuedMsgs(out uint? amount, out Exception? exception) try { // check connection to server - if (!Connected) - { - throw new InvalidOperationException(nameof(QueuedMsgs)); - } + if (!Connected) throw new InvalidOperationException(nameof(QueuedMsgs)); // get number of messages in queue amount = _channel?.MessageCount(Settings.Queue); @@ -685,18 +635,19 @@ public bool QueuedMsgs(out uint? amount, out Exception? exception) sw.Stop(); // invoke associated event - OnQueuedMsgsCompleted(new QueuedMsgsCompletedEventArgs(res, exception, TimeSpan.FromMilliseconds(sw.ElapsedMilliseconds), amount)); + OnQueuedMsgsCompleted(new QueuedMsgsCompletedEventArgs(res, exception, + TimeSpan.FromMilliseconds(sw.ElapsedMilliseconds), amount)); // return the result return res; } #endregion - + #region private event invokation /// - /// This method invokes the envent handlers. + /// This method invokes the envent handlers. /// /// private void OnConnectCompleted(ConnectCompletedEventArgs e) @@ -709,7 +660,7 @@ private void OnConnectCompleted(ConnectCompletedEventArgs e) } /// - /// This method invokes the envent handlers. + /// This method invokes the envent handlers. /// /// private void OnDisconnectCompleted(DisconnectCompletedEventArgs e) @@ -722,7 +673,7 @@ private void OnDisconnectCompleted(DisconnectCompletedEventArgs e) } /// - /// This method invokes the envent handlers. + /// This method invokes the envent handlers. /// /// private void OnWriteMsgCompleted(WriteMsgCompletedEventArgs e) @@ -735,7 +686,7 @@ private void OnWriteMsgCompleted(WriteMsgCompletedEventArgs e) } /// - /// This method invokes the envent handlers. + /// This method invokes the envent handlers. /// /// private void OnReadMsgCompleted(ReadMsgCompletedEventArgs e) @@ -748,7 +699,7 @@ private void OnReadMsgCompleted(ReadMsgCompletedEventArgs e) } /// - /// This method invokes the envent handlers. + /// This method invokes the envent handlers. /// /// private void OnAckMsgCompleted(AckMsgCompletedEventArgs e) @@ -761,7 +712,7 @@ private void OnAckMsgCompleted(AckMsgCompletedEventArgs e) } /// - /// This method invokes the envent handlers. + /// This method invokes the envent handlers. /// /// private void OnNackMsgComplete(NackMsgCompletedEventArgs e) @@ -774,7 +725,7 @@ private void OnNackMsgComplete(NackMsgCompletedEventArgs e) } /// - /// This method invokes the envent handlers. + /// This method invokes the envent handlers. /// /// private void OnQueuedMsgsCompleted(QueuedMsgsCompletedEventArgs e) @@ -787,7 +738,7 @@ private void OnQueuedMsgsCompleted(QueuedMsgsCompletedEventArgs e) } /// - /// This method invokes the envent handlers. + /// This method invokes the envent handlers. /// /// private void OnConnectionStateChanged(ConnectionStatusChangedEventArgs e) @@ -800,7 +751,7 @@ private void OnConnectionStateChanged(ConnectionStatusChangedEventArgs e) } /// - /// This method invokes the envent handlers. + /// This method invokes the envent handlers. /// /// private void OnErrorOccurred(ErrorOccurredEventArgs e) @@ -813,4 +764,4 @@ private void OnErrorOccurred(ErrorOccurredEventArgs e) } #endregion -} +} \ No newline at end of file diff --git a/src/jjm.one.RabbitMqClientWrapper/types/RmqcMessage.cs b/src/jjm.one.RabbitMqClientWrapper/types/RmqcMessage.cs index 6596b86..956d50f 100644 --- a/src/jjm.one.RabbitMqClientWrapper/types/RmqcMessage.cs +++ b/src/jjm.one.RabbitMqClientWrapper/types/RmqcMessage.cs @@ -8,11 +8,34 @@ namespace jjm.one.RabbitMqClientWrapper.types; /// -/// This class represents a message which gets send an received to or from the RabbitMQ server. +/// This class represents a message which gets send an received to or from the RabbitMQ server. /// [Serializable] public class RmqcMessage { + #region public events + + /// + /// This events gets invoked when the message got changed. + /// + public event EventHandler? Changed; + + #endregion + + #region private event invokation + + /// + /// This method invokes the envent handlers. + /// + /// + private void OnChanged(List changedMembers) + { + // invoke event handlers + Changed?.Invoke(this, new MsgChangedEventArgs(changedMembers)); + } + + #endregion + #region private members private readonly ulong? _deliveryTag; @@ -31,38 +54,35 @@ public class RmqcMessage #region public members /// - /// The delivery tag of this message. + /// The delivery tag of this message. /// public ulong DeliveryTag => _deliveryTag ?? 0; /// - /// The redelivered flag of this message. + /// The redelivered flag of this message. /// public bool Redelivered => _redelivered ?? false; /// - /// The exchange to which the message was published to. + /// The exchange to which the message was published to. /// public string Exchange => _exchange ?? string.Empty; /// - /// The number of message in the queue. + /// The number of message in the queue. /// public uint MessageCount => _messageCount ?? 0; - + /// - /// The routing key of this message. + /// The routing key of this message. /// public string RoutingKey { get => _routingKey ?? string.Empty; set { - if (_routingKey == value) - { - return; - } - + if (_routingKey == value) return; + // set routing key _routingKey = value; @@ -77,7 +97,7 @@ public string RoutingKey } /// - /// The basic properties of the message. + /// The basic properties of the message. /// [ExcludeFromCodeCoverage] public IBasicProperties? BasicProperties @@ -85,19 +105,13 @@ public IBasicProperties? BasicProperties get => _basicProperties; set { - if (_basicProperties == value) - { - return; - } + if (_basicProperties == value) return; // set basic properties _basicProperties = value; // copy headers - if (BasicProperties is not null) - { - Headers = BasicProperties.Headers; - } + if (BasicProperties is not null) Headers = BasicProperties.Headers; // reset additional fields TimestampWhenReceived = null; @@ -110,26 +124,20 @@ public IBasicProperties? BasicProperties } /// - /// The header entries of the message. + /// The header entries of the message. /// public IDictionary? Headers { get => _headers; set { - if (_headers == value) - { - return; - } - + if (_headers == value) return; + // set headers _headers = value; // copy headers - if (BasicProperties is not null && Headers is not null) - { - BasicProperties.Headers = Headers; - } + if (BasicProperties is not null && Headers is not null) BasicProperties.Headers = Headers; // reset additional fields TimestampWhenReceived = null; @@ -142,18 +150,15 @@ public IDictionary? Headers } /// - /// The body containing the payload of the message. + /// The body containing the payload of the message. /// public byte[]? BodyArray { get => _body; set { - if (_body == value) - { - return; - } - + if (_body == value) return; + // set body _body = value; @@ -168,7 +173,7 @@ public byte[]? BodyArray } /// - /// The body containing the payload of the message.‚ + /// The body containing the payload of the message.‚ /// public string BodyString { @@ -177,80 +182,75 @@ public string BodyString } /// - /// This flag indicates whether the message was received via the client or not. + /// This flag indicates whether the message was received via the client or not. /// public bool WasReceived => TimestampWhenReceived.HasValue; /// - /// The Timestamp when the message was received. + /// The Timestamp when the message was received. /// public DateTime? TimestampWhenReceived { get; internal set; } /// - /// This flag indicates whether the message was send via the client or not. + /// This flag indicates whether the message was send via the client or not. /// public bool WasSend => TimestampWhenSend.HasValue; /// - /// The Timestamp when the message was send. + /// The Timestamp when the message was send. /// public DateTime? TimestampWhenSend { get; internal set; } /// - /// This flag indicates whether the message was acked via the client or not. + /// This flag indicates whether the message was acked via the client or not. /// public bool WasAcked => TimestampWhenAcked.HasValue; /// - /// The Timestamp when the message was send. + /// The Timestamp when the message was send. /// public DateTime? TimestampWhenAcked { get; internal set; } /// - /// This flag indicates whether the message was nacked via the client or not. + /// This flag indicates whether the message was nacked via the client or not. /// public bool WasNAcked => TimestampWhenNAcked.HasValue; /// - /// This flag indicates whether the message was nacked with or without requeue via the client or not. + /// This flag indicates whether the message was nacked with or without requeue via the client or not. /// public bool WasNAckedWithRequeue { get; internal set; } /// - /// The Timestamp when the message was send. + /// The Timestamp when the message was send. /// public DateTime? TimestampWhenNAcked { get; internal set; } /// - /// This flag indicates whether the message was modified. + /// This flag indicates whether the message was modified. /// - public bool WasModified { + public bool WasModified + { get => _wasModified; internal set { - if (value) - { - WasSaved = false; - } + if (value) WasSaved = false; _wasModified = value; - OnChanged(new List{"This information is currently not supported!"}); + OnChanged(new List { "This information is currently not supported!" }); } } /// - /// This flag indicates whether the message was saved. (must be set by user!) + /// This flag indicates whether the message was saved. (must be set by user!) /// public bool WasSaved { get => _wasSaved; set { - if (value) - { - WasModified = false; - } + if (value) WasModified = false; _wasSaved = value; } @@ -261,14 +261,14 @@ public bool WasSaved #region ctors /// - /// The default constructor of the class. + /// The default constructor of the class. /// public RmqcMessage() { } /// - /// The additional parameterized constructor of the class. + /// The additional parameterized constructor of the class. /// /// public RmqcMessage(BasicGetResult? rawMessage) @@ -287,27 +287,4 @@ public RmqcMessage(BasicGetResult? rawMessage) } #endregion - - #region public events - - /// - /// This events gets invoked when the message got changed. - /// - public event EventHandler? Changed; - - #endregion - - #region private event invokation - - /// - /// This method invokes the envent handlers. - /// - /// - private void OnChanged(List changedMembers) - { - // invoke event handlers - Changed?.Invoke(this, new MsgChangedEventArgs(changedMembers)); - } - - #endregion -} +} \ No newline at end of file diff --git a/src/jjm.one.RabbitMqClientWrapper/types/RmqcSettings.cs b/src/jjm.one.RabbitMqClientWrapper/types/RmqcSettings.cs index 8eb5b52..69182d3 100644 --- a/src/jjm.one.RabbitMqClientWrapper/types/RmqcSettings.cs +++ b/src/jjm.one.RabbitMqClientWrapper/types/RmqcSettings.cs @@ -3,7 +3,7 @@ namespace jjm.one.RabbitMqClientWrapper.types; /// -/// This class defines the settings for a client connection to a RabbitMQ server. +/// This class defines the settings for a client connection to a RabbitMQ server. /// public class RmqcSettings { @@ -22,9 +22,8 @@ public class RmqcSettings #region public members /// - /// The hostname of the RabbitMQ server. - /// - /// default value: localhost + /// The hostname of the RabbitMQ server. + /// default value: localhost /// public virtual string Hostname { @@ -33,9 +32,8 @@ public virtual string Hostname } /// - /// The port of the RabbitMQ server. - /// - /// default value: 5672 + /// The port of the RabbitMQ server. + /// default value: 5672 /// public virtual int Port { @@ -44,9 +42,8 @@ public virtual int Port } /// - /// The username of a RabbitMQ server user. - /// - /// default value: guest + /// The username of a RabbitMQ server user. + /// default value: guest /// public virtual string Username { @@ -55,9 +52,8 @@ public virtual string Username } /// - /// The password of a RabbitMQ server user. - /// - /// default value: guest + /// The password of a RabbitMQ server user. + /// default value: guest /// public virtual string Password { @@ -66,9 +62,8 @@ public virtual string Password } /// - /// The virtual host at the RabbitMQ server. - /// - /// default value: / + /// The virtual host at the RabbitMQ server. + /// default value: / /// public virtual string VirtualHost { @@ -77,9 +72,8 @@ public virtual string VirtualHost } /// - /// The exchange at the RabbitMQ server. - /// - /// default value: amq.direct + /// The exchange at the RabbitMQ server. + /// default value: amq.direct /// public virtual string Exchange { @@ -88,9 +82,8 @@ public virtual string Exchange } /// - /// The queue at the RabbitMQ server. - /// - /// default value: "" + /// The queue at the RabbitMQ server. + /// default value: "" /// public virtual string Queue { @@ -103,7 +96,7 @@ public virtual string Queue #region ctor's /// - /// The default constructor of the class. + /// The default constructor of the class. /// public RmqcSettings() { @@ -117,7 +110,7 @@ public RmqcSettings() } /// - /// The parameterized constructor of the class. + /// The parameterized constructor of the class. /// /// The hostname of the RabbitMQ server. /// The port of the RabbitMQ server. @@ -126,7 +119,7 @@ public RmqcSettings() /// The virtual host at the RabbitMQ server. /// The exchange at the RabbitMQ server. /// The queue at the RabbitMQ server. - public RmqcSettings(string? hostname = null , int? port = null, string? username = null, string? password = null, + public RmqcSettings(string? hostname = null, int? port = null, string? username = null, string? password = null, string? virtualHost = null, string? exchange = null, string? queue = null) { _hostname = hostname; @@ -143,10 +136,13 @@ public RmqcSettings(string? hostname = null , int? port = null, string? username #region public overide /// - /// Determines whether the specified object is equal to the current object. + /// Determines whether the specified object is equal to the current object. /// /// The specified object. - /// if the specified object is equal to the current object, otherwise, . + /// + /// if the specified object is equal to the current object, otherwise, + /// . + /// public override bool Equals(object? obj) { //Check for null and compare run-time types. @@ -154,28 +150,26 @@ public override bool Equals(object? obj) { return false; } - else - { - var s = (RmqcSettings)obj; - - var res = true; - - res &= Hostname.Equals(s.Hostname); - res &= Port.Equals(s.Port); - res &= Username.Equals(s.Username); - res &= Password.Equals(s.Password); - res &= VirtualHost.Equals(s.VirtualHost); - res &= Exchange.Equals(s.Exchange); - res &= Queue.Equals(s.Queue); - - return res; - } + + var s = (RmqcSettings)obj; + + var res = true; + + res &= Hostname.Equals(s.Hostname); + res &= Port.Equals(s.Port); + res &= Username.Equals(s.Username); + res &= Password.Equals(s.Password); + res &= VirtualHost.Equals(s.VirtualHost); + res &= Exchange.Equals(s.Exchange); + res &= Queue.Equals(s.Queue); + + return res; } /// - /// Serves as the default hash function for the class. + /// Serves as the default hash function for the class. /// - /// A hash code for the current object. + /// A hash code for the current object. public override int GetHashCode() { var hashCode = 655511358; @@ -190,4 +184,4 @@ public override int GetHashCode() } #endregion -} +} \ No newline at end of file diff --git a/src/jjm.one.RabbitMqClientWrapper/types/events/AckMsgCompletedEventArgs.cs b/src/jjm.one.RabbitMqClientWrapper/types/events/AckMsgCompletedEventArgs.cs index 75535be..e7608b2 100644 --- a/src/jjm.one.RabbitMqClientWrapper/types/events/AckMsgCompletedEventArgs.cs +++ b/src/jjm.one.RabbitMqClientWrapper/types/events/AckMsgCompletedEventArgs.cs @@ -4,39 +4,15 @@ namespace jjm.one.RabbitMqClientWrapper.types.events; /// -/// This class represents the event args for a ack completed event. +/// This class represents the event args for a ack completed event. /// [ExcludeFromCodeCoverage] public class AckMsgCompletedEventArgs : EventArgs { - #region public members - - /// - /// The flag indicates whether sending the ack to the RabbitMQ server was successfully completed or not. - /// - public bool Successful { get; set; } - - /// - /// The exception which may have occurred during sending the ack to the RabbitMQ server. - /// - public Exception? Exception { get; set; } - - /// - /// The amount of time it took to send the ack to the RabbitMQ server. - /// - public TimeSpan? CompletionTime { get; set; } - - /// - /// The delivery tag of the ack msg. - /// - public ulong? DeliveryTag { get; set; } - - #endregion - #region ctor /// - /// The default constructor of the class. + /// The default constructor of the class. /// /// /// @@ -52,4 +28,28 @@ public AckMsgCompletedEventArgs(bool successful = false, Exception? exception = } #endregion + + #region public members + + /// + /// The flag indicates whether sending the ack to the RabbitMQ server was successfully completed or not. + /// + public bool Successful { get; set; } + + /// + /// The exception which may have occurred during sending the ack to the RabbitMQ server. + /// + public Exception? Exception { get; set; } + + /// + /// The amount of time it took to send the ack to the RabbitMQ server. + /// + public TimeSpan? CompletionTime { get; set; } + + /// + /// The delivery tag of the ack msg. + /// + public ulong? DeliveryTag { get; set; } + + #endregion } \ No newline at end of file diff --git a/src/jjm.one.RabbitMqClientWrapper/types/events/ConnectCompletedEventArgs.cs b/src/jjm.one.RabbitMqClientWrapper/types/events/ConnectCompletedEventArgs.cs index 80563b2..4857e14 100644 --- a/src/jjm.one.RabbitMqClientWrapper/types/events/ConnectCompletedEventArgs.cs +++ b/src/jjm.one.RabbitMqClientWrapper/types/events/ConnectCompletedEventArgs.cs @@ -4,34 +4,15 @@ namespace jjm.one.RabbitMqClientWrapper.types.events; /// -/// This class represents the event args for a connection completed event. +/// This class represents the event args for a connection completed event. /// [ExcludeFromCodeCoverage] public class ConnectCompletedEventArgs : EventArgs { - #region public members - - /// - /// The flag indicates whether connecting to the RabbitMQ server was successfully completed or not. - /// - public bool Successful { get; set; } - - /// - /// The exception which may have occurred during connecting to the RabbitMQ server. - /// - public Exception? Exception { get; set; } - - /// - /// The amount of time it took to connect to the RabbitMQ server. - /// - public TimeSpan? CompletionTime { get; set; } - - #endregion - #region ctor /// - /// The default constructor of the class. + /// The default constructor of the class. /// /// /// @@ -45,4 +26,23 @@ public ConnectCompletedEventArgs(bool successful = false, Exception? exception = } #endregion + + #region public members + + /// + /// The flag indicates whether connecting to the RabbitMQ server was successfully completed or not. + /// + public bool Successful { get; set; } + + /// + /// The exception which may have occurred during connecting to the RabbitMQ server. + /// + public Exception? Exception { get; set; } + + /// + /// The amount of time it took to connect to the RabbitMQ server. + /// + public TimeSpan? CompletionTime { get; set; } + + #endregion } \ No newline at end of file diff --git a/src/jjm.one.RabbitMqClientWrapper/types/events/ConnectionStatusChangedEventArgs.cs b/src/jjm.one.RabbitMqClientWrapper/types/events/ConnectionStatusChangedEventArgs.cs index 0811e03..448ece3 100644 --- a/src/jjm.one.RabbitMqClientWrapper/types/events/ConnectionStatusChangedEventArgs.cs +++ b/src/jjm.one.RabbitMqClientWrapper/types/events/ConnectionStatusChangedEventArgs.cs @@ -4,24 +4,15 @@ namespace jjm.one.RabbitMqClientWrapper.types.events; /// -/// This class represents the event args for a connection status changed event. +/// This class represents the event args for a connection status changed event. /// [ExcludeFromCodeCoverage] public class ConnectionStatusChangedEventArgs : EventArgs { - #region public members - - /// - /// The flag indicates the current connection status. - /// - public bool Status { get; set; } - - #endregion - #region ctor /// - /// The default constructor of the class. + /// The default constructor of the class. /// /// public ConnectionStatusChangedEventArgs(bool status = false) @@ -30,4 +21,13 @@ public ConnectionStatusChangedEventArgs(bool status = false) } #endregion + + #region public members + + /// + /// The flag indicates the current connection status. + /// + public bool Status { get; set; } + + #endregion } \ No newline at end of file diff --git a/src/jjm.one.RabbitMqClientWrapper/types/events/DisconnectCompletedEventArgs.cs b/src/jjm.one.RabbitMqClientWrapper/types/events/DisconnectCompletedEventArgs.cs index 5775e1c..8f78972 100644 --- a/src/jjm.one.RabbitMqClientWrapper/types/events/DisconnectCompletedEventArgs.cs +++ b/src/jjm.one.RabbitMqClientWrapper/types/events/DisconnectCompletedEventArgs.cs @@ -4,34 +4,15 @@ namespace jjm.one.RabbitMqClientWrapper.types.events; /// -/// This class represents the event args for a disconnection completed event. +/// This class represents the event args for a disconnection completed event. /// [ExcludeFromCodeCoverage] public class DisconnectCompletedEventArgs : EventArgs { - #region public members - - /// - /// The flag indicates whether disconnecting from the RabbitMQ server was successfully completed or not. - /// - public bool Successful { get; set; } - - /// - /// The exception which may have occurred during disconnecting from the RabbitMQ server. - /// - public Exception? Exception { get; set; } - - /// - /// The amount of time it took to disconnect from the RabbitMQ server. - /// - public TimeSpan? CompletionTime { get; set; } - - #endregion - #region ctor /// - /// The default constructor of the class. + /// The default constructor of the class. /// /// /// @@ -45,4 +26,23 @@ public DisconnectCompletedEventArgs(bool successful = false, Exception? exceptio } #endregion + + #region public members + + /// + /// The flag indicates whether disconnecting from the RabbitMQ server was successfully completed or not. + /// + public bool Successful { get; set; } + + /// + /// The exception which may have occurred during disconnecting from the RabbitMQ server. + /// + public Exception? Exception { get; set; } + + /// + /// The amount of time it took to disconnect from the RabbitMQ server. + /// + public TimeSpan? CompletionTime { get; set; } + + #endregion } \ No newline at end of file diff --git a/src/jjm.one.RabbitMqClientWrapper/types/events/ErrorOccurredEventArgs.cs b/src/jjm.one.RabbitMqClientWrapper/types/events/ErrorOccurredEventArgs.cs index 85eb4cb..4b23310 100644 --- a/src/jjm.one.RabbitMqClientWrapper/types/events/ErrorOccurredEventArgs.cs +++ b/src/jjm.one.RabbitMqClientWrapper/types/events/ErrorOccurredEventArgs.cs @@ -4,24 +4,15 @@ namespace jjm.one.RabbitMqClientWrapper.types.events; /// -/// This class represents the event args for a error occurred event. +/// This class represents the event args for a error occurred event. /// [ExcludeFromCodeCoverage] public class ErrorOccurredEventArgs : EventArgs { - #region public members - - /// - /// The exception which may have occurred. - /// - public Exception? Exception { get; set; } - - #endregion - #region ctor /// - /// The default constructor of the class. + /// The default constructor of the class. /// /// public ErrorOccurredEventArgs(Exception? exception = null) @@ -30,4 +21,13 @@ public ErrorOccurredEventArgs(Exception? exception = null) } #endregion + + #region public members + + /// + /// The exception which may have occurred. + /// + public Exception? Exception { get; set; } + + #endregion } \ No newline at end of file diff --git a/src/jjm.one.RabbitMqClientWrapper/types/events/MsgChangedEventArgs.cs b/src/jjm.one.RabbitMqClientWrapper/types/events/MsgChangedEventArgs.cs index 68b03f5..97a065c 100644 --- a/src/jjm.one.RabbitMqClientWrapper/types/events/MsgChangedEventArgs.cs +++ b/src/jjm.one.RabbitMqClientWrapper/types/events/MsgChangedEventArgs.cs @@ -5,24 +5,15 @@ namespace jjm.one.RabbitMqClientWrapper.types.events; /// -/// This class represents the event args for a message changed event. +/// This class represents the event args for a message changed event. /// [ExcludeFromCodeCoverage] public class MsgChangedEventArgs : EventArgs { - #region public members - - /// - /// The list of the names of all changed members. - /// - public List ChangedMembers { get; set; } - - #endregion - #region ctor /// - /// The default constructor of the class. + /// The default constructor of the class. /// /// public MsgChangedEventArgs(List? changedMembers) @@ -31,4 +22,13 @@ public MsgChangedEventArgs(List? changedMembers) } #endregion + + #region public members + + /// + /// The list of the names of all changed members. + /// + public List ChangedMembers { get; set; } + + #endregion } \ No newline at end of file diff --git a/src/jjm.one.RabbitMqClientWrapper/types/events/NackMsgCompletedEventArgs.cs b/src/jjm.one.RabbitMqClientWrapper/types/events/NackMsgCompletedEventArgs.cs index 5796c76..37c7710 100644 --- a/src/jjm.one.RabbitMqClientWrapper/types/events/NackMsgCompletedEventArgs.cs +++ b/src/jjm.one.RabbitMqClientWrapper/types/events/NackMsgCompletedEventArgs.cs @@ -4,39 +4,15 @@ namespace jjm.one.RabbitMqClientWrapper.types.events; /// -/// This class represents the event args for a nack completed event. +/// This class represents the event args for a nack completed event. /// [ExcludeFromCodeCoverage] public class NackMsgCompletedEventArgs : EventArgs { - #region public members - - /// - /// The flag indicates whether sending the nack to the RabbitMQ server was successfully completed or not. - /// - public bool Successful { get; set; } - - /// - /// The exception which may have occurred during sending the nack to the RabbitMQ server. - /// - public Exception? Exception { get; set; } - - /// - /// The amount of time it took to send the nack to the RabbitMQ server. - /// - public TimeSpan? CompletionTime { get; set; } - - /// - /// The delivery tag of the nack msg. - /// - public ulong? DeliveryTag { get; set; } - - #endregion - #region ctor /// - /// The default constructor of the class. + /// The default constructor of the class. /// /// /// @@ -52,4 +28,28 @@ public NackMsgCompletedEventArgs(bool successful = false, Exception? exception = } #endregion + + #region public members + + /// + /// The flag indicates whether sending the nack to the RabbitMQ server was successfully completed or not. + /// + public bool Successful { get; set; } + + /// + /// The exception which may have occurred during sending the nack to the RabbitMQ server. + /// + public Exception? Exception { get; set; } + + /// + /// The amount of time it took to send the nack to the RabbitMQ server. + /// + public TimeSpan? CompletionTime { get; set; } + + /// + /// The delivery tag of the nack msg. + /// + public ulong? DeliveryTag { get; set; } + + #endregion } \ No newline at end of file diff --git a/src/jjm.one.RabbitMqClientWrapper/types/events/QueuedMsgsCompletedEventArgs.cs b/src/jjm.one.RabbitMqClientWrapper/types/events/QueuedMsgsCompletedEventArgs.cs index 5335b27..ff0651c 100644 --- a/src/jjm.one.RabbitMqClientWrapper/types/events/QueuedMsgsCompletedEventArgs.cs +++ b/src/jjm.one.RabbitMqClientWrapper/types/events/QueuedMsgsCompletedEventArgs.cs @@ -4,39 +4,15 @@ namespace jjm.one.RabbitMqClientWrapper.types.events; /// -/// This class represents the event args for a queued msg's completed event. +/// This class represents the event args for a queued msg's completed event. /// [ExcludeFromCodeCoverage] public class QueuedMsgsCompletedEventArgs : EventArgs { - #region public members - - /// - /// The flag indicates whether getting the amount of queued msg's from the RabbitMQ server was successfully completed or not. - /// - public bool Successful { get; set; } - - /// - /// The exception which may have occurred during getting the amount of queued msg's from the RabbitMQ server. - /// - public Exception? Exception { get; set; } - - /// - /// The amount of time it took to get the amount of queued msg's from the RabbitMQ server. - /// - public TimeSpan? CompletionTime { get; set; } - - /// - /// The amount of queued msg's in the queue. - /// - public uint? Amount { get; set; } - - #endregion - #region ctor /// - /// The default constructor of the class. + /// The default constructor of the class. /// /// /// @@ -52,4 +28,29 @@ public QueuedMsgsCompletedEventArgs(bool successful = false, Exception? exceptio } #endregion + + #region public members + + /// + /// The flag indicates whether getting the amount of queued msg's from the RabbitMQ server was successfully completed + /// or not. + /// + public bool Successful { get; set; } + + /// + /// The exception which may have occurred during getting the amount of queued msg's from the RabbitMQ server. + /// + public Exception? Exception { get; set; } + + /// + /// The amount of time it took to get the amount of queued msg's from the RabbitMQ server. + /// + public TimeSpan? CompletionTime { get; set; } + + /// + /// The amount of queued msg's in the queue. + /// + public uint? Amount { get; set; } + + #endregion } \ No newline at end of file diff --git a/src/jjm.one.RabbitMqClientWrapper/types/events/ReConnectCompletedEventArgs.cs b/src/jjm.one.RabbitMqClientWrapper/types/events/ReConnectCompletedEventArgs.cs index cf36358..40826f7 100644 --- a/src/jjm.one.RabbitMqClientWrapper/types/events/ReConnectCompletedEventArgs.cs +++ b/src/jjm.one.RabbitMqClientWrapper/types/events/ReConnectCompletedEventArgs.cs @@ -4,34 +4,15 @@ namespace jjm.one.RabbitMqClientWrapper.types.events; /// -/// This class represents the event args for a re-connection completed event. +/// This class represents the event args for a re-connection completed event. /// [ExcludeFromCodeCoverage] public class ReConnectCompletedEventArgs : EventArgs { - #region public members - - /// - /// The flag indicates whether re-connecting to the RabbitMQ server was successfully completed or not. - /// - public bool Successful { get; set; } - - /// - /// The exception which may have occurred during re-connecting to the RabbitMQ server. - /// - public Exception? Exception { get; set; } - - /// - /// The amount of time it took to re-connect to the RabbitMQ server. - /// - public TimeSpan? CompletionTime { get; set; } - - #endregion - #region ctor /// - /// The default constructor of the class. + /// The default constructor of the class. /// /// /// @@ -45,4 +26,23 @@ public ReConnectCompletedEventArgs(bool successful = false, Exception? exception } #endregion + + #region public members + + /// + /// The flag indicates whether re-connecting to the RabbitMQ server was successfully completed or not. + /// + public bool Successful { get; set; } + + /// + /// The exception which may have occurred during re-connecting to the RabbitMQ server. + /// + public Exception? Exception { get; set; } + + /// + /// The amount of time it took to re-connect to the RabbitMQ server. + /// + public TimeSpan? CompletionTime { get; set; } + + #endregion } \ No newline at end of file diff --git a/src/jjm.one.RabbitMqClientWrapper/types/events/ReadMsgCompletedEventArgs.cs b/src/jjm.one.RabbitMqClientWrapper/types/events/ReadMsgCompletedEventArgs.cs index dd3d790..227401e 100644 --- a/src/jjm.one.RabbitMqClientWrapper/types/events/ReadMsgCompletedEventArgs.cs +++ b/src/jjm.one.RabbitMqClientWrapper/types/events/ReadMsgCompletedEventArgs.cs @@ -4,39 +4,15 @@ namespace jjm.one.RabbitMqClientWrapper.types.events; /// -/// This class represents the event args for a read completed event. +/// This class represents the event args for a read completed event. /// [ExcludeFromCodeCoverage] public class ReadMsgCompletedEventArgs : EventArgs { - #region public members - - /// - /// The flag indicates whether reading a messages from the RabbitMQ server was successfully completed or not. - /// - public bool Successful { get; set; } - - /// - /// The exception which may have occurred during reading a messages from the RabbitMQ server. - /// - public Exception? Exception { get; set; } - - /// - /// The amount of time it took to read a message from the RabbitMQ server. - /// - public TimeSpan? CompletionTime { get; set; } - - /// - /// The read message. - /// - public RmqcMessage? Message { get; set; } - - #endregion - #region ctor /// - /// The default constructor of the class. + /// The default constructor of the class. /// /// /// @@ -52,4 +28,28 @@ public ReadMsgCompletedEventArgs(bool successful = false, Exception? exception = } #endregion + + #region public members + + /// + /// The flag indicates whether reading a messages from the RabbitMQ server was successfully completed or not. + /// + public bool Successful { get; set; } + + /// + /// The exception which may have occurred during reading a messages from the RabbitMQ server. + /// + public Exception? Exception { get; set; } + + /// + /// The amount of time it took to read a message from the RabbitMQ server. + /// + public TimeSpan? CompletionTime { get; set; } + + /// + /// The read message. + /// + public RmqcMessage? Message { get; set; } + + #endregion } \ No newline at end of file diff --git a/src/jjm.one.RabbitMqClientWrapper/types/events/WriteMsgCompletedEventArgs.cs b/src/jjm.one.RabbitMqClientWrapper/types/events/WriteMsgCompletedEventArgs.cs index 569668d..3dbef24 100644 --- a/src/jjm.one.RabbitMqClientWrapper/types/events/WriteMsgCompletedEventArgs.cs +++ b/src/jjm.one.RabbitMqClientWrapper/types/events/WriteMsgCompletedEventArgs.cs @@ -4,34 +4,15 @@ namespace jjm.one.RabbitMqClientWrapper.types.events; /// -/// This class represents the event args for a write completed event. +/// This class represents the event args for a write completed event. /// [ExcludeFromCodeCoverage] public class WriteMsgCompletedEventArgs : EventArgs { - #region public members - - /// - /// The flag indicates whether writing a message to the RabbitMQ server was successfully completed or not. - /// - public bool Successful { get; set; } - - /// - /// The exception which may have occurred during writing a message to the RabbitMQ server. - /// - public Exception? Exception { get; set; } - - /// - /// The amount of time it took to write a message to the RabbitMQ server. - /// - public TimeSpan? CompletionTime { get; set; } - - #endregion - #region ctor /// - /// The default constructor of the class. + /// The default constructor of the class. /// /// /// @@ -45,4 +26,23 @@ public WriteMsgCompletedEventArgs(bool successful = false, Exception? exception } #endregion + + #region public members + + /// + /// The flag indicates whether writing a message to the RabbitMQ server was successfully completed or not. + /// + public bool Successful { get; set; } + + /// + /// The exception which may have occurred during writing a message to the RabbitMQ server. + /// + public Exception? Exception { get; set; } + + /// + /// The amount of time it took to write a message to the RabbitMQ server. + /// + public TimeSpan? CompletionTime { get; set; } + + #endregion } \ No newline at end of file diff --git a/src/jjm.one.RabbitMqClientWrapper/types/exceptions/NoChannelException.cs b/src/jjm.one.RabbitMqClientWrapper/types/exceptions/NoChannelException.cs index 9cc5b30..c727bde 100644 --- a/src/jjm.one.RabbitMqClientWrapper/types/exceptions/NoChannelException.cs +++ b/src/jjm.one.RabbitMqClientWrapper/types/exceptions/NoChannelException.cs @@ -1,13 +1,12 @@ using System; -using System.Diagnostics.CodeAnalysis; -using System.Runtime.Serialization; using jjm.one.RabbitMqClientWrapper.main.core; using RabbitMQ.Client; namespace jjm.one.RabbitMqClientWrapper.types.exceptions; /// -/// This class represents an exception which gets thrown if the in a object is null or not initialized. +/// This class represents an exception which gets thrown if the in a +/// object is null or not initialized. /// [Serializable] public class NoChannelException : Exception @@ -15,7 +14,7 @@ public class NoChannelException : Exception #region ctors /// - /// The default constructor of the class. + /// The default constructor of the class. /// public NoChannelException() : base($"The {nameof(IModel)} is null! " + diff --git a/src/jjm.one.RabbitMqClientWrapper/types/exceptions/NoConnectionException.cs b/src/jjm.one.RabbitMqClientWrapper/types/exceptions/NoConnectionException.cs index b72b9bc..a92ab25 100644 --- a/src/jjm.one.RabbitMqClientWrapper/types/exceptions/NoConnectionException.cs +++ b/src/jjm.one.RabbitMqClientWrapper/types/exceptions/NoConnectionException.cs @@ -1,13 +1,12 @@ using System; -using System.Diagnostics.CodeAnalysis; -using System.Runtime.Serialization; using jjm.one.RabbitMqClientWrapper.main.core; using RabbitMQ.Client; namespace jjm.one.RabbitMqClientWrapper.types.exceptions; /// -/// This class represents an exception which gets thrown if the in a object is null or not initialized. +/// This class represents an exception which gets thrown if the in a +/// object is null or not initialized. /// [Serializable] public class NoConnectionException : Exception @@ -15,9 +14,9 @@ public class NoConnectionException : Exception #region ctors /// - /// The default constructor of the class. + /// The default constructor of the class. /// - public NoConnectionException() : + public NoConnectionException() : base($"The {nameof(IConnection)} is null! " + $"Maybe the {nameof(RmqcCore)} was not initialized properly.") { diff --git a/src/jjm.one.RabbitMqClientWrapper/types/exceptions/NoConnectionFactoryException.cs b/src/jjm.one.RabbitMqClientWrapper/types/exceptions/NoConnectionFactoryException.cs index 8e2ae99..e2e7581 100644 --- a/src/jjm.one.RabbitMqClientWrapper/types/exceptions/NoConnectionFactoryException.cs +++ b/src/jjm.one.RabbitMqClientWrapper/types/exceptions/NoConnectionFactoryException.cs @@ -1,13 +1,12 @@ using System; -using System.Diagnostics.CodeAnalysis; -using System.Runtime.Serialization; using jjm.one.RabbitMqClientWrapper.main.core; using RabbitMQ.Client; namespace jjm.one.RabbitMqClientWrapper.types.exceptions; /// -/// This class represents an exception which gets thrown if the in a object is null or not initialized. +/// This class represents an exception which gets thrown if the in a +/// object is null or not initialized. /// [Serializable] public class NoConnectionFactoryException : Exception @@ -15,9 +14,9 @@ public class NoConnectionFactoryException : Exception #region ctors /// - /// The default constructor of the class. + /// The default constructor of the class. /// - public NoConnectionFactoryException() : + public NoConnectionFactoryException() : base($"The {nameof(IConnectionFactory)} is null! " + $"Maybe the {nameof(RmqcCore)} was not initialized properly.") { diff --git a/src/jjm.one.RabbitMqClientWrapper/types/exceptions/UnInitializedClientException.cs b/src/jjm.one.RabbitMqClientWrapper/types/exceptions/UnInitializedClientException.cs index 8746299..f7c176c 100644 --- a/src/jjm.one.RabbitMqClientWrapper/types/exceptions/UnInitializedClientException.cs +++ b/src/jjm.one.RabbitMqClientWrapper/types/exceptions/UnInitializedClientException.cs @@ -1,11 +1,10 @@ using System; -using System.Diagnostics.CodeAnalysis; -using System.Runtime.Serialization; namespace jjm.one.RabbitMqClientWrapper.types.exceptions; /// -/// This class represents an exception which gets thrown if the client is not initialized properly before performing an action. +/// This class represents an exception which gets thrown if the client is not initialized properly before performing an +/// action. /// [Serializable] public class UnInitializedClientException : Exception @@ -13,26 +12,26 @@ public class UnInitializedClientException : Exception #region public members /// - /// The name of the operation which causes the exception. + /// The name of the operation which causes the exception. /// public string? Operation { get; set; } #endregion - + #region ctors /// - /// The default constructor of the class. + /// The default constructor of the class. /// - public UnInitializedClientException() : + public UnInitializedClientException() : base("Client must be initialized and connected to perform this operation!") { } - + /// - /// A parameterized constructor of the class. + /// A parameterized constructor of the class. /// - public UnInitializedClientException(string operation) : + public UnInitializedClientException(string operation) : base($"Client must be initialized and connected to perform the {operation} operation!") { Operation = operation;