diff --git a/Examples/01-PublishSubscribe/01-PublishSubscribe.csproj b/Examples/01-PublishSubscribe/01-PublishSubscribe.csproj
index 9d3fabd..bb77e7f 100644
--- a/Examples/01-PublishSubscribe/01-PublishSubscribe.csproj
+++ b/Examples/01-PublishSubscribe/01-PublishSubscribe.csproj
@@ -11,7 +11,6 @@
-
@@ -20,7 +19,6 @@
-
diff --git a/Examples/01-PublishSubscribe/Program.cs b/Examples/01-PublishSubscribe/Program.cs
index aaf32ad..89c1f9b 100644
--- a/Examples/01-PublishSubscribe/Program.cs
+++ b/Examples/01-PublishSubscribe/Program.cs
@@ -13,8 +13,6 @@ using Tapeti.DataAnnotations;
using Tapeti.Default;
using Tapeti.Ninject;
using Tapeti.SimpleInjector;
-using Tapeti.UnityContainer;
-using Unity;
using Container = SimpleInjector.Container;
// ReSharper disable UnusedMember.Global
@@ -30,7 +28,6 @@ namespace _01_PublishSubscribe
// or use your IoC container of choice:
//var dependencyResolver = GetAutofacDependencyResolver();
//var dependencyResolver = GetCastleWindsorDependencyResolver();
- //var dependencyResolver = GetUnityDependencyResolver();
//var dependencyResolver = GetNinjectDependencyResolver();
// This helper is used because this example is not run as a service. You do not
@@ -131,17 +128,6 @@ namespace _01_PublishSubscribe
}
- internal static IDependencyContainer GetUnityDependencyResolver()
- {
- var container = new UnityContainer();
-
- container.RegisterType();
- container.RegisterType();
-
- return new UnityDependencyResolver(container);
- }
-
-
internal static IDependencyContainer GetNinjectDependencyResolver()
{
var kernel = new StandardKernel();
diff --git a/Examples/ExampleLib/ExampleConsoleApp.cs b/Examples/ExampleLib/ExampleConsoleApp.cs
index feabdec..94aa865 100644
--- a/Examples/ExampleLib/ExampleConsoleApp.cs
+++ b/Examples/ExampleLib/ExampleConsoleApp.cs
@@ -79,7 +79,7 @@ namespace ExampleLib
{
while (true)
{
- if (!(e is AggregateException aggregateException))
+ if (e is not AggregateException aggregateException)
return e;
if (aggregateException.InnerExceptions.Count != 1)
diff --git a/Examples/Messaging.TapetiExample/Messaging.TapetiExample.csproj b/Examples/Messaging.TapetiExample/Messaging.TapetiExample.csproj
index 13e2b2e..43a8b0c 100644
--- a/Examples/Messaging.TapetiExample/Messaging.TapetiExample.csproj
+++ b/Examples/Messaging.TapetiExample/Messaging.TapetiExample.csproj
@@ -6,7 +6,7 @@
-
+
diff --git a/Tapeti.Autofac/AutofacDependencyResolver.cs b/Tapeti.Autofac/AutofacDependencyResolver.cs
index 74ac975..9346674 100644
--- a/Tapeti.Autofac/AutofacDependencyResolver.cs
+++ b/Tapeti.Autofac/AutofacDependencyResolver.cs
@@ -2,9 +2,10 @@
using Autofac;
using Autofac.Builder;
+// ReSharper disable UnusedMember.Global
+
namespace Tapeti.Autofac
{
- ///
///
/// Dependency resolver and container implementation for Autofac.
/// Since this class needs access to both the ContainerBuilder and the built IContainer,
@@ -83,7 +84,7 @@ namespace Tapeti.Autofac
{
CheckContainerBuilder();
containerBuilder
- .Register(context => factory())
+ .Register(_ => factory())
.As()
.PreserveExistingDefaults();
}
@@ -116,7 +117,7 @@ namespace Tapeti.Autofac
{
CheckContainerBuilder();
containerBuilder
- .Register(context => factory())
+ .Register(_ => factory())
.As()
.SingleInstance()
.PreserveExistingDefaults();
diff --git a/Tapeti.Autofac/Tapeti.Autofac.csproj b/Tapeti.Autofac/Tapeti.Autofac.csproj
index e0263c8..57996d9 100644
--- a/Tapeti.Autofac/Tapeti.Autofac.csproj
+++ b/Tapeti.Autofac/Tapeti.Autofac.csproj
@@ -15,7 +15,7 @@
-
+
diff --git a/Tapeti.CastleWindsor/Tapeti.CastleWindsor.csproj b/Tapeti.CastleWindsor/Tapeti.CastleWindsor.csproj
index 9df8c90..21b5dfb 100644
--- a/Tapeti.CastleWindsor/Tapeti.CastleWindsor.csproj
+++ b/Tapeti.CastleWindsor/Tapeti.CastleWindsor.csproj
@@ -15,7 +15,7 @@
-
+
diff --git a/Tapeti.CastleWindsor/WindsorDependencyResolver.cs b/Tapeti.CastleWindsor/WindsorDependencyResolver.cs
index e398157..95d5f5e 100644
--- a/Tapeti.CastleWindsor/WindsorDependencyResolver.cs
+++ b/Tapeti.CastleWindsor/WindsorDependencyResolver.cs
@@ -4,7 +4,6 @@ using Castle.Windsor;
namespace Tapeti.CastleWindsor
{
- ///
///
/// Dependency resolver and container implementation for Castle Windsor.
///
diff --git a/Tapeti.DataAnnotations/DataAnnotationsExtension.cs b/Tapeti.DataAnnotations/DataAnnotationsExtension.cs
index abdbc5c..11ac2b3 100644
--- a/Tapeti.DataAnnotations/DataAnnotationsExtension.cs
+++ b/Tapeti.DataAnnotations/DataAnnotationsExtension.cs
@@ -3,7 +3,6 @@ using Tapeti.Config;
namespace Tapeti.DataAnnotations
{
- ///
///
/// Provides the DataAnnotations validation middleware.
///
diff --git a/Tapeti.DataAnnotations/DataAnnotationsMessageMiddleware.cs b/Tapeti.DataAnnotations/DataAnnotationsMessageMiddleware.cs
index d2df50a..6b3a723 100644
--- a/Tapeti.DataAnnotations/DataAnnotationsMessageMiddleware.cs
+++ b/Tapeti.DataAnnotations/DataAnnotationsMessageMiddleware.cs
@@ -5,7 +5,6 @@ using Tapeti.Config;
namespace Tapeti.DataAnnotations
{
- ///
///
/// Validates consumed messages using System.ComponentModel.DataAnnotations
///
diff --git a/Tapeti.DataAnnotations/DataAnnotationsPublishMiddleware.cs b/Tapeti.DataAnnotations/DataAnnotationsPublishMiddleware.cs
index 7908cda..025d056 100644
--- a/Tapeti.DataAnnotations/DataAnnotationsPublishMiddleware.cs
+++ b/Tapeti.DataAnnotations/DataAnnotationsPublishMiddleware.cs
@@ -5,7 +5,6 @@ using Tapeti.Config;
namespace Tapeti.DataAnnotations
{
- ///
///
/// Validates published messages using System.ComponentModel.DataAnnotations
///
diff --git a/Tapeti.Flow.SQL/SqlConnectionFlowRepository.cs b/Tapeti.Flow.SQL/SqlConnectionFlowRepository.cs
index bdf3979..afe5611 100644
--- a/Tapeti.Flow.SQL/SqlConnectionFlowRepository.cs
+++ b/Tapeti.Flow.SQL/SqlConnectionFlowRepository.cs
@@ -11,7 +11,6 @@ using Newtonsoft.Json;
namespace Tapeti.Flow.SQL
{
- ///
///
/// IFlowRepository implementation for SQL server.
///
diff --git a/Tapeti.Flow.SQL/SqlExceptionHelper.cs b/Tapeti.Flow.SQL/SqlExceptionHelper.cs
index e4d507e..5237a6e 100644
--- a/Tapeti.Flow.SQL/SqlExceptionHelper.cs
+++ b/Tapeti.Flow.SQL/SqlExceptionHelper.cs
@@ -13,7 +13,7 @@ namespace Tapeti.Flow.SQL
// 2627: Violation of %ls constraint '%.*ls'. Cannot insert duplicate key in object '%.*ls'. The duplicate key value is %ls.
public static bool IsDuplicateKey(SqlException e)
{
- return e != null && (e.Number == 2601 || e.Number == 2627);
+ return e is { Number: 2601 or 2627 };
}
@@ -21,12 +21,12 @@ namespace Tapeti.Flow.SQL
{
switch (e)
{
- case TimeoutException _:
+ case TimeoutException:
return true;
- case Exception exception:
+ case not null:
{
- var sqlExceptions = ExtractSqlExceptions(exception);
+ var sqlExceptions = ExtractSqlExceptions(e);
return sqlExceptions.Select(UnwrapSqlErrors).Any(IsRecoverableSQLError);
}
diff --git a/Tapeti.Flow/Annotations/ContinuationAttribute.cs b/Tapeti.Flow/Annotations/ContinuationAttribute.cs
index 2612a30..e1fa2c3 100644
--- a/Tapeti.Flow/Annotations/ContinuationAttribute.cs
+++ b/Tapeti.Flow/Annotations/ContinuationAttribute.cs
@@ -2,7 +2,6 @@
namespace Tapeti.Flow.Annotations
{
- ///
///
/// Marks a message handler as a response message handler which continues a Tapeti Flow.
/// The method only receives direct messages, and does not create a routing key based binding to the queue.
diff --git a/Tapeti.Flow/Annotations/StartAttribute.cs b/Tapeti.Flow/Annotations/StartAttribute.cs
index 8c1fd2e..d43c274 100644
--- a/Tapeti.Flow/Annotations/StartAttribute.cs
+++ b/Tapeti.Flow/Annotations/StartAttribute.cs
@@ -3,7 +3,6 @@ using JetBrains.Annotations;
namespace Tapeti.Flow.Annotations
{
- ///
///
/// Marks this method as the start of a Tapeti Flow. Use IFlowStarter.Start to begin a new flow and
/// call this method. Must return an IYieldPoint.
diff --git a/Tapeti.Flow/ConfigExtensions.cs b/Tapeti.Flow/ConfigExtensions.cs
index 474da6a..5bc973d 100644
--- a/Tapeti.Flow/ConfigExtensions.cs
+++ b/Tapeti.Flow/ConfigExtensions.cs
@@ -1,5 +1,7 @@
using Tapeti.Config;
+// ReSharper disable UnusedMember.Global
+
namespace Tapeti.Flow
{
///
diff --git a/Tapeti.Flow/Default/FlowBindingMiddleware.cs b/Tapeti.Flow/Default/FlowBindingMiddleware.cs
index 877f890..1cb9d6d 100644
--- a/Tapeti.Flow/Default/FlowBindingMiddleware.cs
+++ b/Tapeti.Flow/Default/FlowBindingMiddleware.cs
@@ -60,7 +60,7 @@ namespace Tapeti.Flow.Default
}
else if (context.Result.Info.ParameterType == typeof(void))
{
- context.Result.SetHandler((messageContext, value) => HandleParallelResponse(messageContext));
+ context.Result.SetHandler((messageContext, _) => HandleParallelResponse(messageContext));
}
else
throw new ArgumentException($"Result type must be IYieldPoint, Task or void in controller {context.Method.DeclaringType?.FullName}, method {context.Method.Name}");
diff --git a/Tapeti.Flow/Default/FlowHandlerContext.cs b/Tapeti.Flow/Default/FlowHandlerContext.cs
index c1e8c38..c533c4b 100644
--- a/Tapeti.Flow/Default/FlowHandlerContext.cs
+++ b/Tapeti.Flow/Default/FlowHandlerContext.cs
@@ -3,7 +3,6 @@ using Tapeti.Config;
namespace Tapeti.Flow.Default
{
- ///
///
/// Default implementation for IFlowHandlerContext
///
diff --git a/Tapeti.Flow/Default/FlowProvider.cs b/Tapeti.Flow/Default/FlowProvider.cs
index 3c8c515..eb99d18 100644
--- a/Tapeti.Flow/Default/FlowProvider.cs
+++ b/Tapeti.Flow/Default/FlowProvider.cs
@@ -206,7 +206,7 @@ namespace Tapeti.Flow.Default
///
public async ValueTask Execute(IFlowHandlerContext context, IYieldPoint yieldPoint)
{
- if (!(yieldPoint is DelegateYieldPoint executableYieldPoint))
+ if (yieldPoint is not DelegateYieldPoint executableYieldPoint)
throw new YieldPointException($"Yield point is required in controller {context.Controller.GetType().Name} for method {context.Method.Name}");
FlowContext flowContext = null;
@@ -297,8 +297,8 @@ namespace Tapeti.Flow.Default
{
private class RequestInfo
{
- public object Message { get; set; }
- public ResponseHandlerInfo ResponseHandlerInfo { get; set; }
+ public object Message { get; init; }
+ public ResponseHandlerInfo ResponseHandlerInfo { get; init; }
}
@@ -372,21 +372,13 @@ namespace Tapeti.Flow.Default
{
if (requests.Count == 0)
{
- switch (noRequestsBehaviour)
+ return noRequestsBehaviour switch
{
- case FlowNoRequestsBehaviour.Exception:
- throw new YieldPointException("At least one request must be added before yielding a parallel request");
-
- case FlowNoRequestsBehaviour.Converge:
- return new DelegateYieldPoint(context =>
- flowProvider.Converge(context, convergeMethod.Method.Name, convergeMethodSync));
-
- case FlowNoRequestsBehaviour.EndFlow:
- return new DelegateYieldPoint(EndFlow);
-
- default:
- throw new ArgumentOutOfRangeException(nameof(noRequestsBehaviour), noRequestsBehaviour, null);
- }
+ FlowNoRequestsBehaviour.Exception => throw new YieldPointException("At least one request must be added before yielding a parallel request"),
+ FlowNoRequestsBehaviour.Converge => new DelegateYieldPoint(context => flowProvider.Converge(context, convergeMethod.Method.Name, convergeMethodSync)),
+ FlowNoRequestsBehaviour.EndFlow => new DelegateYieldPoint(EndFlow),
+ _ => throw new ArgumentOutOfRangeException(nameof(noRequestsBehaviour), noRequestsBehaviour, null)
+ };
}
if (convergeMethod?.Method == null)
diff --git a/Tapeti.Flow/Default/FlowStarter.cs b/Tapeti.Flow/Default/FlowStarter.cs
index f391fe8..238947e 100644
--- a/Tapeti.Flow/Default/FlowStarter.cs
+++ b/Tapeti.Flow/Default/FlowStarter.cs
@@ -6,7 +6,6 @@ using Tapeti.Config;
namespace Tapeti.Flow.Default
{
- ///
///
/// Default implementation for IFlowStarter.
///
diff --git a/Tapeti.Flow/Default/FlowState.cs b/Tapeti.Flow/Default/FlowState.cs
index eb7961d..a6ce743 100644
--- a/Tapeti.Flow/Default/FlowState.cs
+++ b/Tapeti.Flow/Default/FlowState.cs
@@ -18,7 +18,7 @@ namespace Tapeti.Flow.Default
///
public FlowMetadata Metadata
{
- get => metadata ?? (metadata = new FlowMetadata());
+ get => metadata ??= new FlowMetadata();
set => metadata = value;
}
@@ -34,7 +34,7 @@ namespace Tapeti.Flow.Default
///
public Dictionary Continuations
{
- get => continuations ?? (continuations = new Dictionary());
+ get => continuations ??= new Dictionary();
set => continuations = value;
}
diff --git a/Tapeti.Flow/Default/FlowStore.cs b/Tapeti.Flow/Default/FlowStore.cs
index 99fe5f0..324f121 100644
--- a/Tapeti.Flow/Default/FlowStore.cs
+++ b/Tapeti.Flow/Default/FlowStore.cs
@@ -9,7 +9,6 @@ using Tapeti.Flow.FlowHelpers;
namespace Tapeti.Flow.Default
{
- ///
///
/// Default implementation of IFlowStore.
///
@@ -119,7 +118,7 @@ namespace Tapeti.Flow.Default
if (!loaded)
throw new InvalidOperationException("Flow store is not yet loaded.");
- return new ValueTask(continuationLookup.TryGetValue(continuationID, out var result) ? result : (Guid?)null);
+ return new ValueTask(continuationLookup.TryGetValue(continuationID, out var result) ? result : null);
}
diff --git a/Tapeti.Flow/Default/NonPersistentFlowRepository.cs b/Tapeti.Flow/Default/NonPersistentFlowRepository.cs
index bbaa40d..0ac6ecc 100644
--- a/Tapeti.Flow/Default/NonPersistentFlowRepository.cs
+++ b/Tapeti.Flow/Default/NonPersistentFlowRepository.cs
@@ -5,7 +5,6 @@ using System.Threading.Tasks;
namespace Tapeti.Flow.Default
{
- ///
///
/// Default implementation for IFlowRepository. Does not persist any state, relying on the FlowStore's cache instead.
///
diff --git a/Tapeti.Flow/FlowExtension.cs b/Tapeti.Flow/FlowExtension.cs
index 6c979e9..cc28e1e 100644
--- a/Tapeti.Flow/FlowExtension.cs
+++ b/Tapeti.Flow/FlowExtension.cs
@@ -4,7 +4,6 @@ using Tapeti.Flow.Default;
namespace Tapeti.Flow
{
- ///
///
/// Provides the Flow middleware.
///
diff --git a/Tapeti.Flow/FlowHelpers/MethodSerializer.cs b/Tapeti.Flow/FlowHelpers/MethodSerializer.cs
index 229ad65..c11c6eb 100644
--- a/Tapeti.Flow/FlowHelpers/MethodSerializer.cs
+++ b/Tapeti.Flow/FlowHelpers/MethodSerializer.cs
@@ -35,8 +35,6 @@ namespace Tapeti.Flow.FlowHelpers
try
{
assembly = Assembly.Load(match.Groups["assembly"].Value);
- if (assembly == null)
- return null;
}
catch
{
diff --git a/Tapeti.Flow/IFlowHandlerContext.cs b/Tapeti.Flow/IFlowHandlerContext.cs
index 921dd4e..0b99556 100644
--- a/Tapeti.Flow/IFlowHandlerContext.cs
+++ b/Tapeti.Flow/IFlowHandlerContext.cs
@@ -4,7 +4,6 @@ using Tapeti.Config;
namespace Tapeti.Flow
{
- ///
///
/// Provides information about the handler for the flow.
///
diff --git a/Tapeti.Flow/IFlowStore.cs b/Tapeti.Flow/IFlowStore.cs
index 9766e5b..38dc328 100644
--- a/Tapeti.Flow/IFlowStore.cs
+++ b/Tapeti.Flow/IFlowStore.cs
@@ -42,7 +42,6 @@ namespace Tapeti.Flow
}
- ///
///
/// Represents a lock on the flow state, to provide thread safety.
///
diff --git a/Tapeti.Flow/ResponseExpectedException.cs b/Tapeti.Flow/ResponseExpectedException.cs
index 07d66b1..8c0d225 100644
--- a/Tapeti.Flow/ResponseExpectedException.cs
+++ b/Tapeti.Flow/ResponseExpectedException.cs
@@ -2,7 +2,6 @@
namespace Tapeti.Flow
{
- ///
///
/// Raised when a response is expected to end a flow, but none was provided.
///
diff --git a/Tapeti.Flow/Tapeti.Flow.csproj b/Tapeti.Flow/Tapeti.Flow.csproj
index d991a6c..6fc172c 100644
--- a/Tapeti.Flow/Tapeti.Flow.csproj
+++ b/Tapeti.Flow/Tapeti.Flow.csproj
@@ -36,6 +36,6 @@
-
+
diff --git a/Tapeti.Flow/YieldPointException.cs b/Tapeti.Flow/YieldPointException.cs
index 2d135d0..a0eed51 100644
--- a/Tapeti.Flow/YieldPointException.cs
+++ b/Tapeti.Flow/YieldPointException.cs
@@ -2,7 +2,6 @@
namespace Tapeti.Flow
{
- ///
///
/// Raised when an invalid yield point is returned.
///
diff --git a/Tapeti.Ninject/NinjectDependencyResolver.cs b/Tapeti.Ninject/NinjectDependencyResolver.cs
index 0e2fdcf..4f2b791 100644
--- a/Tapeti.Ninject/NinjectDependencyResolver.cs
+++ b/Tapeti.Ninject/NinjectDependencyResolver.cs
@@ -4,7 +4,6 @@ using Ninject;
namespace Tapeti.Ninject
{
- ///
///
/// Dependency resolver and container implementation for Ninject.
///
@@ -49,7 +48,7 @@ namespace Tapeti.Ninject
if (kernel.GetBindings(typeof(TService)).Any())
return;
- kernel.Bind().ToMethod(context => factory());
+ kernel.Bind().ToMethod(_ => factory());
}
@@ -77,7 +76,7 @@ namespace Tapeti.Ninject
if (kernel.GetBindings(typeof(TService)).Any())
return;
- kernel.Bind().ToMethod(context => factory()).InSingletonScope();
+ kernel.Bind().ToMethod(_ => factory()).InSingletonScope();
}
diff --git a/Tapeti.Ninject/Tapeti.Ninject.csproj b/Tapeti.Ninject/Tapeti.Ninject.csproj
index 2010385..84d56eb 100644
--- a/Tapeti.Ninject/Tapeti.Ninject.csproj
+++ b/Tapeti.Ninject/Tapeti.Ninject.csproj
@@ -15,7 +15,7 @@
-
+
diff --git a/Tapeti.Serilog/Tapeti.Serilog.csproj b/Tapeti.Serilog/Tapeti.Serilog.csproj
index 830f755..2b520d3 100644
--- a/Tapeti.Serilog/Tapeti.Serilog.csproj
+++ b/Tapeti.Serilog/Tapeti.Serilog.csproj
@@ -19,7 +19,7 @@
-
+
diff --git a/Tapeti.Serilog/TapetiSeriLogger.cs b/Tapeti.Serilog/TapetiSeriLogger.cs
index f13afbd..af3de98 100644
--- a/Tapeti.Serilog/TapetiSeriLogger.cs
+++ b/Tapeti.Serilog/TapetiSeriLogger.cs
@@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Text;
using Tapeti.Config;
+using Tapeti.Connection;
using ISerilogLogger = Serilog.ILogger;
// ReSharper disable UnusedMember.Global
@@ -129,7 +130,7 @@ namespace Tapeti.Serilog
}
///
- public void QueueExistsWarning(string queueName, IReadOnlyDictionary existingArguments, IReadOnlyDictionary arguments)
+ public void QueueExistsWarning(string queueName, IRabbitMQArguments existingArguments, IRabbitMQArguments arguments)
{
seriLogger.Warning("Tapeti: durable queue {queueName} exists with incompatible x-arguments ({existingArguments} vs. {arguments}) and will not be redeclared, queue will be consumed as-is",
queueName,
diff --git a/Tapeti.SimpleInjector/SimpleInjectorDependencyResolver.cs b/Tapeti.SimpleInjector/SimpleInjectorDependencyResolver.cs
index c8a189f..0c96418 100644
--- a/Tapeti.SimpleInjector/SimpleInjectorDependencyResolver.cs
+++ b/Tapeti.SimpleInjector/SimpleInjectorDependencyResolver.cs
@@ -4,7 +4,6 @@ using SimpleInjector;
namespace Tapeti.SimpleInjector
{
- ///
///
/// Dependency resolver and container implementation for SimpleInjector.
///
diff --git a/Tapeti.SimpleInjector/Tapeti.SimpleInjector.csproj b/Tapeti.SimpleInjector/Tapeti.SimpleInjector.csproj
index d1e9d4f..c60b753 100644
--- a/Tapeti.SimpleInjector/Tapeti.SimpleInjector.csproj
+++ b/Tapeti.SimpleInjector/Tapeti.SimpleInjector.csproj
@@ -19,7 +19,7 @@
-
+
diff --git a/Tapeti.Tests/Client/TapetiClientTests.cs b/Tapeti.Tests/Client/TapetiClientTests.cs
index 0bebbd7..c9157ba 100644
--- a/Tapeti.Tests/Client/TapetiClientTests.cs
+++ b/Tapeti.Tests/Client/TapetiClientTests.cs
@@ -1,9 +1,12 @@
// Do not include in the Release build for AppVeyor due to the Docker requirement
#if DEBUG
+using System.Text;
using System.Threading;
using System.Threading.Tasks;
using FluentAssertions;
using Tapeti.Connection;
+using Tapeti.Default;
+using Tapeti.Exceptions;
using Tapeti.Tests.Mock;
using Xunit;
using Xunit.Abstractions;
@@ -11,11 +14,14 @@ using Xunit.Abstractions;
namespace Tapeti.Tests.Client
{
[Collection(RabbitMQCollection.Name)]
- public class TapetiClientTests
+ public class TapetiClientTests : IAsyncLifetime
{
private readonly RabbitMQFixture fixture;
private readonly MockDependencyResolver dependencyResolver = new();
+ private TapetiClient client;
+
+
public TapetiClientTests(RabbitMQFixture fixture, ITestOutputHelper testOutputHelper)
{
this.fixture = fixture;
@@ -24,6 +30,22 @@ namespace Tapeti.Tests.Client
}
+ public Task InitializeAsync()
+ {
+ client = CreateClient();
+
+ return Task.CompletedTask;
+ }
+
+
+ public async Task DisposeAsync()
+ {
+ await client.Close();
+ client = null;
+ }
+
+
+
[Fact]
public void Fixture()
{
@@ -35,31 +57,50 @@ namespace Tapeti.Tests.Client
[Fact]
public async Task DynamicQueueDeclareNoPrefix()
{
- var client = CreateCilent();
-
var queueName = await client.DynamicQueueDeclare(null, null, CancellationToken.None);
queueName.Should().NotBeNullOrEmpty();
-
- await client.Close();
}
[Fact]
public async Task DynamicQueueDeclarePrefix()
{
- var client = CreateCilent();
-
var queueName = await client.DynamicQueueDeclare("dynamicprefix", null, CancellationToken.None);
queueName.Should().StartWith("dynamicprefix");
+ }
- await client.Close();
+
+ [Fact]
+ public async Task PublishHandleOverflow()
+ {
+ var queue1 = await client.DynamicQueueDeclare(null, new RabbitMQArguments
+ {
+ { "x-max-length", 5 },
+ { "x-overflow", "reject-publish" }
+ }, CancellationToken.None);
+
+ var queue2 = await client.DynamicQueueDeclare(null, null, CancellationToken.None);
+
+ var body = Encoding.UTF8.GetBytes("Hello world!");
+ var properties = new MessageProperties();
+
+
+ for (var i = 0; i < 5; i++)
+ await client.Publish(body, properties, null, queue1, true);
+
+
+ var publishOverMaxLength = () => client.Publish(body, properties, null, queue1, true);
+ await publishOverMaxLength.Should().ThrowAsync();
+
+ // The channel should recover and allow further publishing
+ await client.Publish(body, properties, null, queue2, true);
}
// TODO test the other methods
- private TapetiClient CreateCilent()
+ private TapetiClient CreateClient()
{
return new TapetiClient(
new TapetiConfig.Config(dependencyResolver),
diff --git a/Tapeti.Tests/Config/QueueArgumentsTest.cs b/Tapeti.Tests/Config/QueueArgumentsTest.cs
index a43e5bb..ebb8cbc 100644
--- a/Tapeti.Tests/Config/QueueArgumentsTest.cs
+++ b/Tapeti.Tests/Config/QueueArgumentsTest.cs
@@ -18,7 +18,7 @@ namespace Tapeti.Tests.Config
private static readonly MockRepository MoqRepository = new(MockBehavior.Strict);
private readonly Mock client;
- private readonly Dictionary> declaredQueues = new();
+ private readonly Dictionary declaredQueues = new();
public QueueArgumentsTest()
@@ -45,8 +45,8 @@ namespace Tapeti.Tests.Config
var queue = 0;
client
- .Setup(c => c.DynamicQueueDeclare(null, It.IsAny>(), It.IsAny()))
- .Callback((string _, IReadOnlyDictionary arguments, CancellationToken _) =>
+ .Setup(c => c.DynamicQueueDeclare(null, It.IsAny(), It.IsAny()))
+ .Callback((string _, IRabbitMQArguments arguments, CancellationToken _) =>
{
queue++;
declaredQueues.Add($"queue-{queue}", arguments);
@@ -54,8 +54,8 @@ namespace Tapeti.Tests.Config
.ReturnsAsync(() => $"queue-{queue}");
client
- .Setup(c => c.DurableQueueDeclare(It.IsAny(), It.IsAny>(), It.IsAny>(), It.IsAny()))
- .Callback((string queueName, IEnumerable _, IReadOnlyDictionary arguments, CancellationToken _) =>
+ .Setup(c => c.DurableQueueDeclare(It.IsAny(), It.IsAny>(), It.IsAny(), It.IsAny()))
+ .Callback((string queueName, IEnumerable _, IRabbitMQArguments arguments, CancellationToken _) =>
{
declaredQueues.Add(queueName, arguments);
})
@@ -89,10 +89,10 @@ namespace Tapeti.Tests.Config
var arguments = declaredQueues["queue-1"];
arguments.Should().ContainKey("x-custom").WhoseValue.Should().Be("custom value");
- arguments.Should().ContainKey("x-another").WhoseValue.Should().Be("another value");
- arguments.Should().ContainKey("x-max-length").WhoseValue.Should().Be("100");
- arguments.Should().ContainKey("x-max-length-bytes").WhoseValue.Should().Be("100000");
- arguments.Should().ContainKey("x-message-ttl").WhoseValue.Should().Be("4269");
+ arguments.Should().ContainKey("x-another").WhoseValue.Should().Be(true);
+ arguments.Should().ContainKey("x-max-length").WhoseValue.Should().Be(100);
+ arguments.Should().ContainKey("x-max-length-bytes").WhoseValue.Should().Be(100000);
+ arguments.Should().ContainKey("x-message-ttl").WhoseValue.Should().Be(4269);
arguments.Should().ContainKey("x-overflow").WhoseValue.Should().Be("reject-publish");
}
@@ -108,10 +108,10 @@ namespace Tapeti.Tests.Config
declaredQueues.Should().HaveCount(2);
var arguments1 = declaredQueues["queue-1"];
- arguments1.Should().ContainKey("x-max-length").WhoseValue.Should().Be("100");
+ arguments1.Should().ContainKey("x-max-length").WhoseValue.Should().Be(100);
var arguments2 = declaredQueues["queue-2"];
- arguments2.Should().ContainKey("x-max-length-bytes").WhoseValue.Should().Be("100000");
+ arguments2.Should().ContainKey("x-max-length-bytes").WhoseValue.Should().Be(100000);
}
@@ -148,7 +148,7 @@ namespace Tapeti.Tests.Config
[DynamicQueue]
- [QueueArguments("x-custom", "custom value", "x-another", "another value", MaxLength = 100, MaxLengthBytes = 100000, MessageTTL = 4269, Overflow = RabbitMQOverflow.RejectPublish)]
+ [QueueArguments("x-custom", "custom value", "x-another", true, MaxLength = 100, MaxLengthBytes = 100000, MessageTTL = 4269, Overflow = RabbitMQOverflow.RejectPublish)]
private class TestController
{
public void HandleMessage1(TestMessage1 message)
diff --git a/Tapeti.Tests/Mock/MockLogger.cs b/Tapeti.Tests/Mock/MockLogger.cs
index a2d2387..19c41fb 100644
--- a/Tapeti.Tests/Mock/MockLogger.cs
+++ b/Tapeti.Tests/Mock/MockLogger.cs
@@ -1,7 +1,7 @@
using System;
-using System.Collections.Generic;
using System.Text;
using Tapeti.Config;
+using Tapeti.Connection;
using Xunit.Abstractions;
namespace Tapeti.Tests.Mock
@@ -49,7 +49,7 @@ namespace Tapeti.Tests.Mock
: $"Declaring {(durable ? "durable" : "dynamic")} queue {queueName}");
}
- public void QueueExistsWarning(string queueName, IReadOnlyDictionary existingArguments, IReadOnlyDictionary arguments)
+ public void QueueExistsWarning(string queueName, IRabbitMQArguments existingArguments, IRabbitMQArguments arguments)
{
var argumentsText = new StringBuilder();
foreach (var pair in arguments)
diff --git a/Tapeti.Transient/ConfigExtensions.cs b/Tapeti.Transient/ConfigExtensions.cs
index aba7641..43a069c 100644
--- a/Tapeti.Transient/ConfigExtensions.cs
+++ b/Tapeti.Transient/ConfigExtensions.cs
@@ -1,6 +1,8 @@
using System;
using Tapeti.Config;
+// ReSharper disable UnusedMember.Global
+
namespace Tapeti.Transient
{
///
diff --git a/Tapeti.Transient/TransientGenericBinding.cs b/Tapeti.Transient/TransientGenericBinding.cs
index a514466..0617c62 100644
--- a/Tapeti.Transient/TransientGenericBinding.cs
+++ b/Tapeti.Transient/TransientGenericBinding.cs
@@ -4,7 +4,6 @@ using Tapeti.Config;
namespace Tapeti.Transient
{
- ///
///
/// Implements a binding for transient request response messages.
/// Register this binding using the WithTransient config extension method.
diff --git a/Tapeti.Transient/TransientPublisher.cs b/Tapeti.Transient/TransientPublisher.cs
index 3092c86..fb1f713 100644
--- a/Tapeti.Transient/TransientPublisher.cs
+++ b/Tapeti.Transient/TransientPublisher.cs
@@ -2,7 +2,6 @@
namespace Tapeti.Transient
{
- ///
///
/// Default implementation of ITransientPublisher
///
diff --git a/Tapeti.Transient/TransientRouter.cs b/Tapeti.Transient/TransientRouter.cs
index 7c0e94d..96c27af 100644
--- a/Tapeti.Transient/TransientRouter.cs
+++ b/Tapeti.Transient/TransientRouter.cs
@@ -55,7 +55,7 @@ namespace Tapeti.Transient
public async Task