Inheritance: IDotnetTestMessageHandler
コード例 #1
0
ファイル: DotnetTest.cs プロジェクト: singhsarab/cli
        private void HandleMessage(Message message)
        {
            foreach (var messageHandler in _messageHandlers)
            {
                var nextState = messageHandler.HandleMessage(this, message);

                if (nextState != DotnetTestState.NoOp)
                {
                    State = nextState;
                    return;
                }
            }

            UnknownMessageHandler.HandleMessage(this, message);
        }
コード例 #2
0
        public void It_throws_InvalidOperationException_and_sends_an_error_when_the_message_is_not_handled()
        {
            const string expectedError = "No handler for message 'Test Message' when at state 'InitialState'";

            var dotnetTestMock = new Mock<IDotnetTest>();
            dotnetTestMock.Setup(d => d.State).Returns(DotnetTestState.InitialState);

            var reportingChannel = new Mock<IReportingChannel>();
            reportingChannel.Setup(r => r.SendError(expectedError)).Verifiable();

            var unknownMessageHandler = new UnknownMessageHandler(reportingChannel.Object);

            Action action = () => unknownMessageHandler.HandleMessage(
                dotnetTestMock.Object,
                new Message { MessageType = "Test Message" });

            action.ShouldThrow<InvalidOperationException>().WithMessage(expectedError);

            reportingChannel.Verify();
        }