Esempio n. 1
0
        public void GivenAMessageHandledByMultipleHandlers_WhenAskedToProcess_ShouldInvokeAllCommandHandlersInCorrectSequence()
        {
            var processor = new CommandProcessorTestDataBuilder().Build();

            var command = new CommandHandledByMultipleHandlers();

            processor.Process(command);

            var expected =
                new[]
            {
                typeof(ObjectCommandHandler),
                typeof(CommandHandlerA),
                typeof(CommandHandlerB)
            };

            CollectionAssert.AreEqual(
                expected,
                command.HandlersThatHandledThisMessage
                .Select(x => x.GetType())
                .ToArray());
        }
Esempio n. 2
0
        public void GivenAMessageHandledByMultipleHandlers_WhenAskedToProcessWithDifferentHandlerOrdering_ShouldInvokeAllCommandHandlersInCorrectSequence()
        {
            Conventions.SetHandlerSortingMethod((x, y) => string.Compare(y.GetType().FullName, x.GetType().FullName, StringComparison.InvariantCultureIgnoreCase));

            var processor = new CommandProcessorTestDataBuilder().Build();

            var command = new CommandHandledByMultipleHandlers();

            processor.Process(command);

            var expected =
                new[]
            {
                typeof(ObjectCommandHandler),
                typeof(CommandHandlerB),
                typeof(CommandHandlerA)
            };

            CollectionAssert.AreEqual(
                expected,
                command.HandlersThatHandledThisMessage
                .Select(x => x.GetType())
                .ToArray());
        }