Exemple #1
0
        public async Task Get_Current_Round(GetCurrentRound query, [Frozen] Mock <IRoundRepository> repoMock, RoundQueryHandler sut, Fixture fixture)
        {
            //Arrange
            var round = fixture.Build <Persistence.Model.Round>()
                        .With(x => x.Id, query.GameId)
                        .Create();

            repoMock.Setup(x => x.GetCurrentRound(query.GameId)).ReturnsAsync(round);

            //Act
            var result = await sut.Handle(query, CancellationToken.None);

            //Assert
            result.ShouldNotBeNull();
            result.ShouldBeOfType <Round>();
            result.GameId.ShouldBe(query.GameId);
        }
Exemple #2
0
        public async Task <Round> Handle(GetCurrentRound request, CancellationToken cancellationToken)
        {
            var round = await _repo.GetCurrentRound(request.GameId);

            if (round == null)
            {
                return(null);
            }

            return(new Round
            {
                Id = round.Id,
                GameId = request.GameId,
                RoundVersion = round.RoundVersion,
                StartedTimestamp = round.StartedTimestamp,
                EndedTimestamp = round.EndedTimestamp,
                Subject = round.Subject
            });
        }