public void WhenSelectingBadHandlerThenThrowsInvalidOperationException() { // Assign DefaultCommandHandlerSelector resolver = this.CreateTestableService(); CommandHandlerRequest request = new CommandHandlerRequest(this.config, new BadCommand()); // Act & assert Assert.Throws <InvalidOperationException>(() => resolver.SelectHandler(request)); }
public void WhenSelectingDuplicateHandlerThenThrowsInvalidOperationException() { // Assign DefaultCommandHandlerSelector resolver = this.CreateTestableService(); CommandHandlerRequest request = new CommandHandlerRequest(this.config, new SimpleCommand()); this.config.Services.Replace(typeof(ICommandHandlerTypeResolver), new DuplicateCommandHandlerTypeResolver()); // Act & assert Assert.Throws <InvalidOperationException>(() => resolver.SelectHandler(request)); }
public void WhenSelectingHandlerThenReturnHandlerDesciptor() { // Assign DefaultCommandHandlerSelector resolver = this.CreateTestableService(); CommandHandlerRequest request = new CommandHandlerRequest(this.config, new SimpleCommand()); this.config.Services.Replace(typeof(ICommandHandlerTypeResolver), new SimpleCommandHandlerTypeResolver()); // Act var descriptor = resolver.SelectHandler(request); // Assert Assert.NotNull(descriptor); Assert.Equal(typeof(SimpleHandler1), descriptor.HandlerType); Assert.Equal(typeof(SimpleCommand), descriptor.MessageType); }