-
Notifications
You must be signed in to change notification settings - Fork 119
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: allow multiple typedHandlers handling the same message type
- Loading branch information
1 parent
b2cbb50
commit deb5b4e
Showing
13 changed files
with
120 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
src/KafkaFlow.IntegrationTests/Core/Handlers/MessageHandler1.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
namespace KafkaFlow.IntegrationTests.Core.Handlers | ||
{ | ||
using System.Threading.Tasks; | ||
using KafkaFlow.TypedHandler; | ||
using Messages; | ||
|
||
public class MessageHandler1 : IMessageHandler<TestMessage1> | ||
{ | ||
public Task Handle(IMessageContext context, TestMessage1 message) | ||
{ | ||
MessageStorage.Add(message); | ||
return Task.CompletedTask; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
src/KafkaFlow.IntegrationTests/Core/Messages/PauseResumeMessage.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
namespace KafkaFlow.IntegrationTests.Core.Messages | ||
{ | ||
using System; | ||
using System.Runtime.Serialization; | ||
|
||
[DataContract] | ||
public class PauseResumeMessage : ITestMessage | ||
{ | ||
[DataMember(Order = 1)] | ||
public Guid Id { get; set; } | ||
|
||
[DataMember(Order = 2)] | ||
public string Value { get; set; } | ||
|
||
[DataMember(Order = 3)] | ||
public int Version { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
src/KafkaFlow.UnitTests/TypedHandler/HandlerTypeMappingTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
namespace KafkaFlow.UnitTests.TypedHandler | ||
{ | ||
using System; | ||
using FluentAssertions; | ||
using KafkaFlow.TypedHandler; | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
|
||
[TestClass] | ||
public class HandlerTypeMappingTests | ||
{ | ||
private HandlerTypeMapping target; | ||
|
||
[TestInitialize] | ||
public void Setup() | ||
{ | ||
this.target = new HandlerTypeMapping(); | ||
} | ||
|
||
[TestMethod] | ||
public void AddSeveralMappings_GetHandlersTypesReturnsListOfHandlers() | ||
{ | ||
// Act | ||
this.target.AddMapping(typeof(int), typeof(string)); | ||
this.target.AddMapping(typeof(int), typeof(double)); | ||
this.target.AddMapping(typeof(int), typeof(bool)); | ||
|
||
// Assert | ||
this.target.GetHandlersTypes(typeof(int)).Should().BeEquivalentTo( | ||
typeof(string), | ||
typeof(double), | ||
typeof(bool)); | ||
} | ||
} | ||
} |