Esempio n. 1
0
        public async Task GetVotesQueryHandlerTests_ReturnsVotesPerParticipant_BasedOnRetrospectiveOptions()
        {
            // Given
            var command = new GetVotesQuery(this._retroId);
            var handler = new GetVotesQueryHandler(this.Context, this.Mapper);

            int laneCount        = this.Context.NoteLanes.Count();
            int votePerLaneCount = this.Context.Retrospectives.Where(x => x.UrlId.StringId == this._retroId).
                                   Select(x => x.Options.MaximumNumberOfVotes).
                                   First();
            int votesPerParticipant = laneCount * votePerLaneCount;

            // When
            RetrospectiveVoteStatus result = (await handler.Handle(command, CancellationToken.None)).VoteStatus;

            // Then
            Assert.That(result.Votes, Has.Count.EqualTo(2 * votesPerParticipant));
            Assert.That(result.VotesByParticipant.Get(this._participant1Id), Has.Count.EqualTo(votesPerParticipant));
            Assert.That(result.VotesByParticipant.Get(this._participant2Id), Has.Count.EqualTo(votesPerParticipant));
            Assert.That(result.VotesByNote.Get(this._note1Id).Select(x => x.ParticipantId),
                        Is.EquivalentTo(new[] { this._participant1Id, this._participant1Id }));
            Assert.That(result.VotesByNote.Get(this._note2Id).Select(x => x.ParticipantId),
                        Is.EquivalentTo(new[] { this._participant1Id, this._participant2Id }));
            Assert.That(result.VotesByNoteGroup.Get(this._noteGroupId).Select(x => x.ParticipantId),
                        Is.EquivalentTo(new[] { this._participant2Id }));
        }
Esempio n. 2
0
        public void GetVotesQueryHandlerTests_ThrowsNotFoundException_WhenNotFound()
        {
            // Given
            const string retroId = "surely-not-found";
            var          query   = new GetVotesQuery(retroId);
            var          handler = new GetVotesQueryHandler(this.Context, this.Mapper);

            // When
            TestDelegate action = () => handler.Handle(query, CancellationToken.None).GetAwaiter().GetResult();

            // Then
            Assert.That(action, Throws.InstanceOf <NotFoundException>());
        }