2017-02-12 14:42:49 +01:00
|
|
|
|
using System;
|
|
|
|
|
using Tapeti.Default;
|
|
|
|
|
using Xunit;
|
|
|
|
|
|
2018-12-19 20:50:56 +01:00
|
|
|
|
namespace Tapeti.Tests
|
2017-02-12 14:42:49 +01:00
|
|
|
|
{
|
|
|
|
|
// ReSharper disable InconsistentNaming
|
|
|
|
|
public class TypeNameRoutingKeyStrategyTests
|
|
|
|
|
{
|
|
|
|
|
private class Example { }
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
public void Singleword()
|
|
|
|
|
{
|
|
|
|
|
AssertRoutingKey("example", typeof(Example));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private class ExampleMessage { }
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
public void SinglewordMessagePostfix()
|
|
|
|
|
{
|
|
|
|
|
AssertRoutingKey("example", typeof(ExampleMessage));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private class ExampleMultiWord { }
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
public void Multiword()
|
|
|
|
|
{
|
|
|
|
|
AssertRoutingKey("example.multi.word", typeof(ExampleMultiWord));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private class ExampleMultiWordMessage { }
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
public void MultiwordMessagePostfix()
|
|
|
|
|
{
|
|
|
|
|
AssertRoutingKey("example.multi.word", typeof(ExampleMultiWordMessage));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private class ACRTestMessage { }
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
public void Acronym()
|
|
|
|
|
{
|
|
|
|
|
AssertRoutingKey("acr.test", typeof(ACRTestMessage));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private class ACRTestMIXEDCaseMESSAGE { }
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
public void MixedCasing()
|
|
|
|
|
{
|
|
|
|
|
AssertRoutingKey("acr.test.mixed.case", typeof(ACRTestMIXEDCaseMESSAGE));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void AssertRoutingKey(string expected, Type messageType)
|
|
|
|
|
{
|
|
|
|
|
if (expected == null) throw new ArgumentNullException(nameof(expected));
|
|
|
|
|
if (messageType == null) throw new ArgumentNullException(nameof(messageType));
|
|
|
|
|
|
|
|
|
|
Assert.Equal(expected, new TypeNameRoutingKeyStrategy().GetRoutingKey(messageType));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// ReSharper restore InconsistentNaming
|
|
|
|
|
}
|