Exemplo n.º 1
0
        public void Publish_GivenScoreViewWhereGameDoesntExist_ThrowsInvalidOperationException()
        {
            var gameSqlQueryService     = Mock.Of <IQuery <GameView> >();
            var gameSqlQueryServiceMock = Mock.Get(gameSqlQueryService);

            gameSqlQueryServiceMock.Setup(s => s.Get(It.IsAny <Guid>(), 1, 1)).Returns(() => Task.FromResult((GameView)null));
            var logger    = Mock.Of <ILogger <RabbitScorePublisherService> >();
            var publisher = new RabbitScorePublisherService(_connection, "exchange", gameSqlQueryService, logger);
            var gameId    = Guid.NewGuid();

            Assert.That(async() => await publisher.Publish(new ScoreView()
            {
                Id       = Guid.NewGuid(),
                GameId   = gameId,
                Name     = "Test User",
                Score    = 0,
                PostedAt = DateTime.UtcNow,
            }), Throws.InvalidOperationException.With.Message.EqualTo($"Game with id {gameId} not found"));
        }
Exemplo n.º 2
0
 public void Publish_GivenNullScoreView_ThrowsArgumentException()
 => Assert.That(async() => await _publisher.Publish(null), Throws.ArgumentException.With.Message.EqualTo("data cannot be null"));