示例#1
0
        public void ServicePublishFail()
        {
            Mock <IMessageBusChannel <GreetingModel> > mock = new Mock <IMessageBusChannel <GreetingModel> >();

            mock.Setup(c => c.Publish(It.IsAny <GreetingModel>())).Throws(new Exception("Could not send message"));

            MessageBusHandler handler = new MessageBusHandler(mock.Object);

            Assert.Throws(Is.TypeOf <Exception>(), () => handler.SendMessage("TestName"), "Could not send message");
        }
示例#2
0
        public void ServicePublishSuccess()
        {
            Mock <IMessageBusChannel <GreetingModel> > mock = new Mock <IMessageBusChannel <GreetingModel> >();

            mock.Setup(c => c.Publish(It.IsAny <GreetingModel>())).Returns(true);

            MessageBusHandler handler = new MessageBusHandler(mock.Object);

            Assert.AreEqual(handler.SendMessage("TestName"), true);
        }