public void PriorityIsIndependentOfRegistryOrder(bool reverseRegistration)
        {
            // Arrange
            var registry = new CommandRegistry(new Mock <ICommandHandlerExecuter>().Object);

            // Act
            if (reverseRegistration)
            {
                registry.Register <SimpleCommandHandlerTwo>(order: 1500);
                registry.Register <SimpleCommandHandler>(order: 1000);
            }
            else
            {
                registry.Register <SimpleCommandHandler>(order: 1000);
                registry.Register <SimpleCommandHandlerTwo>(order: 1500);
            }


            // Assert
            var result = registry.GetPrioritisedCommandHandlers(new SimpleCommand());

            Assert.Collection(result, pca =>
            {
                if (pca.Priority != 1000)
                {
                    throw new Exception("Wrong order");
                }
            }, pca =>
            {
                if (pca.Priority != 1500)
                {
                    throw new Exception("Wrong order");
                }
            });
        }
        public void SimpleCommandHandlerIsRegisteredByObjectType()
        {
            // Arrange
            var registry = new CommandRegistry(new Mock<ICommandHandlerExecuter>().Object);

            // Act
            registry.Register(typeof(SimpleCommandHandler));

            // Assert
            var result = registry.GetPrioritisedCommandHandlers(new SimpleCommand());
            Assert.Equal(typeof(SimpleCommandHandler), result.Single().CommandHandlerType);
        }
        public void CommandHandlersAreRemoved()
        {
            // Arrange
            var registry = new CommandRegistry(new Mock<ICommandHandlerExecuter>().Object);

            // Act
            registry.Register<SimpleCommandHandler>();
            registry.RemoveHandlers<SimpleCommand>();

            // Assert
            Assert.Throws<MissingCommandHandlerRegistrationException>(() =>
                registry.GetPrioritisedCommandHandlers(new SimpleCommand()));
        }