コード例 #1
0
        public void WhenSelectingBadHandlerThenThrowsInvalidOperationException()
        {
            // Assign
            DefaultCommandHandlerSelector resolver = this.CreateTestableService();
            CommandHandlerRequest         request  = new CommandHandlerRequest(this.config, new BadCommand());

            // Act & assert
            Assert.Throws <InvalidOperationException>(() => resolver.SelectHandler(request));
        }
コード例 #2
0
        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));
        }
コード例 #3
0
        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);
        }