2022-11-21 16:59:09 +01:00
|
|
|
|
using System.Linq;
|
|
|
|
|
using FluentAssertions;
|
2023-04-14 15:47:27 +02:00
|
|
|
|
using Tapeti.Config.Annotations;
|
2022-11-21 16:59:09 +01:00
|
|
|
|
using Tapeti.Config;
|
|
|
|
|
using Xunit;
|
|
|
|
|
|
|
|
|
|
namespace Tapeti.Tests.Config
|
|
|
|
|
{
|
|
|
|
|
public class SimpleControllerTest : BaseControllerTest
|
|
|
|
|
{
|
|
|
|
|
[Fact]
|
|
|
|
|
public void RegisterController()
|
|
|
|
|
{
|
|
|
|
|
var bindings = GetControllerBindings<TestController>();
|
2022-11-23 12:52:36 +01:00
|
|
|
|
bindings.Should().HaveCount(2);
|
2022-11-21 16:59:09 +01:00
|
|
|
|
|
|
|
|
|
var handleSimpleMessageBinding = bindings.Single(b => b is IControllerMethodBinding cmb &&
|
|
|
|
|
cmb.Controller == typeof(TestController) &&
|
|
|
|
|
cmb.Method.Name == "HandleSimpleMessage");
|
|
|
|
|
handleSimpleMessageBinding.QueueType.Should().Be(QueueType.Dynamic);
|
2022-11-23 12:52:36 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var handleSimpleMessageStaticBinding = bindings.Single(b => b is IControllerMethodBinding cmb &&
|
|
|
|
|
cmb.Controller == typeof(TestController) &&
|
|
|
|
|
cmb.Method.Name == "HandleSimpleMessageStatic");
|
|
|
|
|
handleSimpleMessageStaticBinding.QueueType.Should().Be(QueueType.Dynamic);
|
|
|
|
|
|
2022-11-21 16:59:09 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// ReSharper disable all
|
|
|
|
|
#pragma warning disable
|
|
|
|
|
|
|
|
|
|
private class TestMessage
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[DynamicQueue]
|
|
|
|
|
private class TestController
|
|
|
|
|
{
|
|
|
|
|
public void HandleSimpleMessage(TestMessage message)
|
|
|
|
|
{
|
|
|
|
|
}
|
2022-11-23 12:52:36 +01:00
|
|
|
|
|
|
|
|
|
public static void HandleSimpleMessageStatic(TestMessage message)
|
|
|
|
|
{
|
|
|
|
|
}
|
2022-11-21 16:59:09 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#pragma warning restore
|
|
|
|
|
// ReSharper restore all
|
|
|
|
|
}
|
|
|
|
|
}
|