Skip to content

Commit

Permalink
Rename messages and handlers in SyncMessageHandlerInvokerLoaderTests
Browse files Browse the repository at this point in the history
  • Loading branch information
ocoanet committed Nov 1, 2023
1 parent e77ed06 commit 7dbb1d2
Showing 1 changed file with 39 additions and 39 deletions.
78 changes: 39 additions & 39 deletions src/Abc.Zebus.Tests/Scan/SyncMessageHandlerInvokerLoaderTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public class SyncMessageHandlerInvokerLoaderTests
public void should_load_queue_name()
{
var invokerLoader = new SyncMessageHandlerInvokerLoader(new Container());
var invoker = invokerLoader.LoadMessageHandlerInvokers(TypeSource.FromType<FakeHandlerWithQueueName1>()).ExpectedSingle();
var invoker = invokerLoader.LoadMessageHandlerInvokers(TypeSource.FromType<TestHandler_DispatchQueue1>()).ExpectedSingle();

invoker.DispatchQueueName.ShouldEqual("DispatchQueue1");
}
Expand All @@ -27,7 +27,7 @@ public void should_load_queue_name()
public void should_subscribe_to_standard_handler_on_startup()
{
var invokerLoader = new SyncMessageHandlerInvokerLoader(new Container());
var invokers = invokerLoader.LoadMessageHandlerInvokers(TypeSource.FromType<FakeHandler>()).ToList();
var invokers = invokerLoader.LoadMessageHandlerInvokers(TypeSource.FromType<TestHandler>()).ToList();

invokers.ShouldHaveSize(2);

Expand All @@ -41,7 +41,7 @@ public void should_subscribe_to_standard_handler_on_startup()
public void should_not_subscribe_to_routable_handler_on_startup()
{
var invokerLoader = new SyncMessageHandlerInvokerLoader(new Container());
var invoker = invokerLoader.LoadMessageHandlerInvokers(TypeSource.FromType<FakeRoutableHandler>()).ExpectedSingle();
var invoker = invokerLoader.LoadMessageHandlerInvokers(TypeSource.FromType<TestRoutableHandler>()).ExpectedSingle();

invoker.GetStartupSubscriptions().ShouldBeEmpty();
}
Expand All @@ -50,26 +50,26 @@ public void should_not_subscribe_to_routable_handler_on_startup()
public void should_subscribe_to_auto_subscribe_routable_message_handler_on_startup()
{
var invokerLoader = new SyncMessageHandlerInvokerLoader(new Container());
var invoker = invokerLoader.LoadMessageHandlerInvokers(TypeSource.FromType<FakeRoutableMessageWithAutoSubscribeHandler>()).ExpectedSingle();
var invoker = invokerLoader.LoadMessageHandlerInvokers(TypeSource.FromType<TestAutoSubscribeRoutableHandler>()).ExpectedSingle();

invoker.GetStartupSubscriptions().ShouldBeEquivalentTo(Subscription.Any<FakeRoutableMessageWithAutoSubscribe>());
invoker.GetStartupSubscriptions().ShouldBeEquivalentTo(Subscription.Any<TestAutoSubscribeRoutableMessage>());
}

[Test]
public void should_subscribe_to_auto_subscribe_routable_message_handler_with_auto_subscription_mode_on_startup()
{
var invokerLoader = new SyncMessageHandlerInvokerLoader(new Container());
var invoker = invokerLoader.LoadMessageHandlerInvokers(TypeSource.FromType<FakeRoutableMessageWithAutoSubscribeHandler_Auto>()).ExpectedSingle();
var invoker = invokerLoader.LoadMessageHandlerInvokers(TypeSource.FromType<TestAutoSubscribeRoutableHandler_AutoSubscriptionMode>()).ExpectedSingle();

invoker.GetStartupSubscriptions().ShouldBeEquivalentTo(Subscription.Any<FakeRoutableMessageWithAutoSubscribe>());
invoker.GetStartupSubscriptions().ShouldBeEquivalentTo(Subscription.Any<TestAutoSubscribeRoutableMessage>());
}


[Test]
public void should_not_subscribe_to_auto_subscribe_routable_message_handler_with_manual_subscription_mode_on_startup()
{
var invokerLoader = new SyncMessageHandlerInvokerLoader(new Container());
var invoker = invokerLoader.LoadMessageHandlerInvokers(TypeSource.FromType<FakeRoutableMessageWithAutoSubscribeHandler_Manual>()).ExpectedSingle();
var invoker = invokerLoader.LoadMessageHandlerInvokers(TypeSource.FromType<TestAutoSubscribeRoutableHandler_ManualSubscriptionMode>()).ExpectedSingle();

invoker.GetStartupSubscriptions().ShouldBeEmpty();
}
Expand All @@ -78,7 +78,7 @@ public void should_not_subscribe_to_auto_subscribe_routable_message_handler_with
public void should_switch_to_manual_subscription_mode_when_specified()
{
var invokerLoader = new SyncMessageHandlerInvokerLoader(new Container());
var invoker = invokerLoader.LoadMessageHandlerInvokers(TypeSource.FromType<FakeHandlerWithManualSubscriptionMode>()).ExpectedSingle();
var invoker = invokerLoader.LoadMessageHandlerInvokers(TypeSource.FromType<TestHandler_ManualSubscriptionMode>()).ExpectedSingle();

invoker.GetStartupSubscriptions().ShouldBeEmpty();
}
Expand All @@ -87,19 +87,19 @@ public void should_switch_to_manual_subscription_mode_when_specified()
public void should_switch_to_auto_subscription_mode_when_specified()
{
var invokerLoader = new SyncMessageHandlerInvokerLoader(new Container());
var invoker = invokerLoader.LoadMessageHandlerInvokers(TypeSource.FromType<FakeRoutableHandlerWithAutoSubscriptionMode>()).ExpectedSingle();
var invoker = invokerLoader.LoadMessageHandlerInvokers(TypeSource.FromType<TestRoutableHandler_AutoSubscriptionMode>()).ExpectedSingle();

var expectedSubscription = Subscription.Any<FakeRoutableMessage>();
var expectedSubscription = Subscription.Any<TestRoutableMessage>();
invoker.GetStartupSubscriptions().ShouldBeEquivalentTo(expectedSubscription);
}

[Test]
public void should_use_startup_subscriber()
{
var invokerLoader = new SyncMessageHandlerInvokerLoader(new Container());
var invoker = invokerLoader.LoadMessageHandlerInvokers(TypeSource.FromType<FakeRoutableHandlerWithStartupSubscriber>()).ExpectedSingle();
var invoker = invokerLoader.LoadMessageHandlerInvokers(TypeSource.FromType<TestRoutableHandler_StartupSubscriber>()).ExpectedSingle();

var expectedSubscription = new Subscription(MessageUtil.TypeId<FakeRoutableMessage>(), new BindingKey("123"));
var expectedSubscription = new Subscription(MessageUtil.TypeId<TestRoutableMessage>(), new BindingKey("123"));
invoker.GetStartupSubscriptions().ShouldBeEquivalentTo(expectedSubscription);
}

Expand All @@ -114,112 +114,112 @@ public void should_throw_exception_if_method_is_async_void()
public void should_not_throw_if_scanning_handler_with_several_handle_methods()
{
var invokerLoader = new SyncMessageHandlerInvokerLoader(new Container());
Assert.DoesNotThrow(() => invokerLoader.LoadMessageHandlerInvokers(TypeSource.FromType<FakeHandler>()).ToList());
Assert.DoesNotThrow(() => invokerLoader.LoadMessageHandlerInvokers(TypeSource.FromType<TestHandler>()).ToList());
}

public class FakeMessage : IMessage
public class TestMessage1 : IMessage
{
}

public class FakeMessage2 : IMessage
public class TestMessage2 : IMessage
{
}

[Routable]
public class FakeRoutableMessage : IMessage
public class TestRoutableMessage : IMessage
{
[RoutingPosition(1)]
public string Key;
}


[Routable(AutoSubscribe = true)]
public class FakeRoutableMessageWithAutoSubscribe : IMessage
public class TestAutoSubscribeRoutableMessage : IMessage
{
[RoutingPosition(1)]
public string Key;
}

public class FakeHandler : IMessageHandler<FakeMessage>, IMessageHandler<FakeMessage2>
public class TestHandler : IMessageHandler<TestMessage1>, IMessageHandler<TestMessage2>
{
public void Handle(FakeMessage message)
public void Handle(TestMessage1 message)
{
throw new NotImplementedException();
}

public void Handle(FakeMessage2 message)
public void Handle(TestMessage2 message)
{
throw new NotImplementedException();
}
}

public class WrongAsyncHandler : IMessageHandler<FakeMessage>
public class WrongAsyncHandler : IMessageHandler<TestMessage1>
{
public async void Handle(FakeMessage message)
public async void Handle(TestMessage1 message)
{
await Task.CompletedTask;
}
}

[DispatchQueueName("DispatchQueue1")]
public class FakeHandlerWithQueueName1 : IMessageHandler<FakeMessage>
public class TestHandler_DispatchQueue1 : IMessageHandler<TestMessage1>
{
public void Handle(FakeMessage message)
public void Handle(TestMessage1 message)
{
}
}

[SubscriptionMode(SubscriptionMode.Manual)]
public class FakeHandlerWithManualSubscriptionMode : IMessageHandler<FakeMessage>
public class TestHandler_ManualSubscriptionMode : IMessageHandler<TestMessage1>
{
public void Handle(FakeMessage message)
public void Handle(TestMessage1 message)
{
}
}

[SubscriptionMode(SubscriptionMode.Auto)]
public class FakeRoutableHandlerWithAutoSubscriptionMode : IMessageHandler<FakeRoutableMessage>
public class TestRoutableHandler_AutoSubscriptionMode : IMessageHandler<TestRoutableMessage>
{
public void Handle(FakeRoutableMessage message)
public void Handle(TestRoutableMessage message)
{
}
}

public class FakeRoutableHandler : IMessageHandler<FakeRoutableMessage>
public class TestRoutableHandler : IMessageHandler<TestRoutableMessage>
{
public void Handle(FakeRoutableMessage message)
public void Handle(TestRoutableMessage message)
{
}
}

public class FakeRoutableMessageWithAutoSubscribeHandler : IMessageHandler<FakeRoutableMessageWithAutoSubscribe>
public class TestAutoSubscribeRoutableHandler : IMessageHandler<TestAutoSubscribeRoutableMessage>
{
public void Handle(FakeRoutableMessageWithAutoSubscribe message)
public void Handle(TestAutoSubscribeRoutableMessage message)
{
}
}

[SubscriptionMode(SubscriptionMode.Auto)]
public class FakeRoutableMessageWithAutoSubscribeHandler_Auto : IMessageHandler<FakeRoutableMessageWithAutoSubscribe>
public class TestAutoSubscribeRoutableHandler_AutoSubscriptionMode : IMessageHandler<TestAutoSubscribeRoutableMessage>
{
public void Handle(FakeRoutableMessageWithAutoSubscribe message)
public void Handle(TestAutoSubscribeRoutableMessage message)
{
}
}

[SubscriptionMode(SubscriptionMode.Manual)]
public class FakeRoutableMessageWithAutoSubscribeHandler_Manual : IMessageHandler<FakeRoutableMessageWithAutoSubscribe>
public class TestAutoSubscribeRoutableHandler_ManualSubscriptionMode : IMessageHandler<TestAutoSubscribeRoutableMessage>
{
public void Handle(FakeRoutableMessageWithAutoSubscribe message)
public void Handle(TestAutoSubscribeRoutableMessage message)
{
}
}


[SubscriptionMode(typeof(StartupSubscriber))]
public class FakeRoutableHandlerWithStartupSubscriber : IMessageHandler<FakeRoutableMessage>
public class TestRoutableHandler_StartupSubscriber : IMessageHandler<TestRoutableMessage>
{
public void Handle(FakeRoutableMessage message)
public void Handle(TestRoutableMessage message)
{
}

Expand Down

0 comments on commit 7dbb1d2

Please sign in to comment.