2022-11-21 15:59:09 +00:00
|
|
|
|
using System.Linq;
|
|
|
|
|
using FluentAssertions;
|
2023-04-14 13:47:27 +00:00
|
|
|
|
using Tapeti.Config.Annotations;
|
2022-11-21 15:59:09 +00: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 11:52:36 +00:00
|
|
|
|
bindings.Should().HaveCount(2);
|
2022-11-21 15:59:09 +00: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 11:52:36 +00: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 15:59:09 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// ReSharper disable all
|
|
|
|
|
#pragma warning disable
|
|
|
|
|
|
|
|
|
|
private class TestMessage
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[DynamicQueue]
|
|
|
|
|
private class TestController
|
|
|
|
|
{
|
|
|
|
|
public void HandleSimpleMessage(TestMessage message)
|
|
|
|
|
{
|
|
|
|
|
}
|
2022-11-23 11:52:36 +00:00
|
|
|
|
|
|
|
|
|
public static void HandleSimpleMessageStatic(TestMessage message)
|
|
|
|
|
{
|
|
|
|
|
}
|
2022-11-21 15:59:09 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#pragma warning restore
|
|
|
|
|
// ReSharper restore all
|
|
|
|
|
}
|
|
|
|
|
}
|