예제 #1
0
        public async Task <string> NextAsync()
        {
            var votingResult = await _votingFinisher.CollectResultAndLockAsync();

            await _unitOfWork.CommitAsync();

            _messageQueueService.Send(Message.DisableVotingMessage);

            Response.OnCompleted(() => OnResponseCompleted(votingResult.Song.Id, _rootLifetimeScopeProvider));

            return(votingResult.Song.FileName);
        }
예제 #2
0
        public async Task CollectResultAndLock_WithWinnerOfVoting_ReturnsWinnerOfVoting()
        {
            // Arrange
            var winnerOfVoting = new SongWithVoteCount
            {
                Song = new Song {
                    Id = Guid.NewGuid()
                },
                VoteCount = 22
            };

            _votingCandidateRepository.GetWinnerOfVotingWithVoteCountOrDefaultAsync().Returns(Task.FromResult(winnerOfVoting));

            // Act
            var result = await _votingFinisher.CollectResultAndLockAsync();

            // Assert
            Assert.That(result, Is.Not.Null);
            Assert.That(result, Is.SameAs(winnerOfVoting));
            Assert.That(result.Song.Id, Is.EqualTo(winnerOfVoting.Song.Id));
            Assert.That(result.VoteCount, Is.EqualTo(winnerOfVoting.VoteCount));
        }