public async Task Publish_GivenModelThatThrows_ReturnsFalse() { var connection = Mock.Of <IConnection>(); var model = Mock.Of <IModel>(); var connectionMock = Mock.Get(connection); var modelMock = Mock.Get(model); connectionMock.Setup(c => c.CreateModel()).Returns(model); modelMock.Setup(m => m.CreateBasicProperties()).Throws <Exception>(); var publisher = new RabbitGamePublisherService(connection, _exchangeName, _logger); var view = new GameView() { Id = Guid.NewGuid(), Name = "Test Name", }; Assert.That(await publisher.Publish(view), Is.False); }
public void Publish_GivenNullGameView_ThrowsArgumentException() => Assert.That(async() => await _publisher.Publish(null), Throws.ArgumentException.With.Message.EqualTo("data cannot be null"));