public void RewritesErrorMessageMatchingCodeAsWarning()
        {
            var wrapped = new Mock <IBrokerageMessageHandler>();

            wrapped.Setup(bmh => bmh.Handle(It.IsAny <BrokerageMessageEvent>())).Verifiable();

            var downgrader = new DowngradeErrorCodeToWarningBrokerageMessageHandler(wrapped.Object, new List <string> {
                "code"
            });
            var message = new BrokerageMessageEvent(BrokerageMessageType.Error, "code", "message");

            downgrader.Handle(message);

            // verify we converter the message to a warning message w/ the same message and code
            wrapped.Verify(
                bmh => bmh.Handle(
                    It.Is <BrokerageMessageEvent>(
                        e => e.Type == BrokerageMessageType.Warning &&
                        e.Message == message.Message &&
                        e.Code == message.Code
                        )
                    ),
                Times.Once
                );
        }
Ejemplo n.º 2
0
        public void PatchesErrorMessageNotMatchingCodeToWrappedImplementation()
        {
            var wrapped = new Mock <IBrokerageMessageHandler>();

            wrapped.Setup(bmh => bmh.Handle(It.IsAny <BrokerageMessageEvent>())).Verifiable();

            var downgrader = new DowngradeErrorCodeToWarningBrokerageMessageHandler(wrapped.Object, new[] { "code" });
            var message    = new BrokerageMessageEvent(BrokerageMessageType.Error, "not-code", "message");

            downgrader.Handle(message);

            wrapped.Verify(bmh => bmh.Handle(message), Times.Once);
        }
        public void PatchesNonErrorMessagesToWrappedImplementation(BrokerageMessageType type)
        {
            var wrapped = new Mock <IBrokerageMessageHandler>();

            wrapped.Setup(bmh => bmh.Handle(It.IsAny <BrokerageMessageEvent>())).Verifiable();

            var downgrader = new DowngradeErrorCodeToWarningBrokerageMessageHandler(wrapped.Object, new List <string> {
                "code"
            });
            var message = new BrokerageMessageEvent(type, "code", "message");

            downgrader.Handle(message);

            wrapped.Verify(bmh => bmh.Handle(message), Times.Once);
        }