public static void RetrospectiveVoteStatus_RemoveVote_RemovesVote() { // Given var voteStatus = new RetrospectiveVoteStatus(3); voteStatus.Votes.Add(new VoteModel { Id = 3, ParticipantId = 1, NoteId = 2, LaneId = 3 }); voteStatus.Votes.Add(new VoteModel { Id = 4, ParticipantId = 1 }); voteStatus.Initialize(); Assume.That(voteStatus.Votes.Count(x => x.IsCast == false), Is.EqualTo(1)); // When voteStatus.Apply(new VoteChange("not-relevant", new VoteModel { Id = 3, ParticipantId = 1, NoteId = 2 }, VoteMutationType.Removed)); // Then Assert.That(voteStatus.Votes.Count(x => x.IsCast == false), Is.EqualTo(2)); }
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 })); }
public async Task <GetShowcaseQueryResult> Handle(GetShowcaseQuery request, CancellationToken cancellationToken) { if (request == null) { throw new ArgumentNullException(nameof(request)); } RetrospectiveStatus retrospective = await this._mediator.Send(new GetRetrospectiveStatusQuery(request.RetroId), cancellationToken); RetrospectiveVoteStatus voteStatus = (await this._mediator.Send(new GetVotesQuery(request.RetroId), cancellationToken)).VoteStatus; var showcaseData = new ShowcaseData(); foreach (RetrospectiveLane retrospectiveLane in retrospective.Lanes) { RetrospectiveLaneContent laneContents = await this._mediator.Send( new GetRetrospectiveLaneContentQuery(request.RetroId, retrospectiveLane.Id), cancellationToken); foreach (RetrospectiveNote note in laneContents.Notes) { showcaseData.Items.Add(new ShowcaseItem(note, retrospectiveLane, voteStatus)); } foreach (RetrospectiveNoteGroup noteGroup in laneContents.Groups) { showcaseData.Items.Add(new ShowcaseItem(noteGroup, retrospectiveLane, voteStatus)); } } showcaseData.Sort(); return(new GetShowcaseQueryResult(showcaseData)); }
public ShowcaseItem(RetrospectiveNote note, RetrospectiveLane lane, RetrospectiveVoteStatus voteStatus) { if (voteStatus == null) { throw new ArgumentNullException(nameof(voteStatus)); } this.Note = note ?? throw new ArgumentNullException(nameof(note)); this.Lane = lane ?? throw new ArgumentNullException(nameof(lane)); this.Votes = voteStatus.VotesByNote.Get(note.Id); }
public GetVotesQueryResult(RetrospectiveVoteStatus voteStatus) { this.VoteStatus = voteStatus; }