Skip to content

Commit

Permalink
feat: Added tests
Browse files Browse the repository at this point in the history
  • Loading branch information
zeryk24 committed Feb 19, 2025
1 parent ba01644 commit fcbde60
Showing 1 changed file with 49 additions and 0 deletions.
49 changes: 49 additions & 0 deletions src/Testing/CoreTests/Configuration/HandlerDiscoveryTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,55 @@ public void assert_on_invalid_handler_types(Type candidateType)
source.IncludeType(candidateType);
});
}

public record Message;
public class MyCustomListener
{
public void Handle(Message message){}
}

[Fact]
public void disabling_conventional_discovery_does_not_disable_custom_discovery()
{
var discovery = new HandlerDiscovery();
discovery.DisableConventionalDiscovery();
discovery.CustomizeHandlerDiscovery(q => q.Includes.WithNameSuffix("CustomListener"));

var discoveredHandlers = discovery.FindCalls(new WolverineOptions())
.Select(x => x.Item1)
.ToList();

discoveredHandlers.ShouldHaveSingleItem();
discoveredHandlers.ShouldContain(typeof(MyCustomListener));
}

[Fact]
public void disabling_conventional_discovery_does_not_exclude_explicit_types()
{
var discovery = new HandlerDiscovery();
discovery.DisableConventionalDiscovery();
discovery.IncludeType<MyCustomListener>();

var discoveredHandlers = discovery.FindCalls(new WolverineOptions())
.Select(x => x.Item1)
.ToList();

discoveredHandlers.ShouldHaveSingleItem();
discoveredHandlers.ShouldContain(typeof(MyCustomListener));
}

[Fact]
public void disabling_conventional_discovery_without_custom_discovery_should_not_find_any_handlers()
{
var discovery = new HandlerDiscovery();
discovery.DisableConventionalDiscovery();

var discoveredHandlers = discovery.FindCalls(new WolverineOptions())
.Select(x => x.Item1)
.ToList();

discoveredHandlers.ShouldBeEmpty();
}
}

internal static class InternalGuy;
Expand Down

0 comments on commit fcbde60

Please sign in to comment.