public async Task AddRoundToSessionItem_given_itemId_returns_new_roundDto() { using (var connection = await this.CreateConnectionAsync()) using (var context = await this.CreateContextAsync(connection)) { var entity = this.CreateDummySessionEntity(); context.Sessions.Add(entity); context.SaveChanges(); var id = entity.Items[0].Id; var repository = new SessionRepository(context); var round = repository.AddRoundToSessionItem(id); Assert.Equal(1, round.Id); } }
public async Task AddVoteToRound_given_vote_and_itemId_returns_new_voteDto() { using (var connection = await this.CreateConnectionAsync()) using (var context = await this.CreateContextAsync(connection)) { var entity = this.CreateDummySessionEntity(); context.Sessions.Add(entity); context.SaveChanges(); var id = entity.Items[0].Id; var repository = new SessionRepository(context); var round = repository.AddRoundToSessionItem(id); var vote = new VoteCreateUpdateDTO { Estimate = 13, UserId = 42 }; var dto = repository.AddVoteToRound(vote, round.Id); Assert.Equal(1, dto.Id); Assert.Equal(13, dto.Estimate); Assert.Equal(42, dto.UserId); } }
public async Task AddVoteToRound_given_vote_and_itemId_inserts_vote() { using (var connection = await this.CreateConnectionAsync()) using (var context = await this.CreateContextAsync(connection)) { var entity = this.CreateDummySessionEntity(); context.Sessions.Add(entity); context.SaveChanges(); var id = entity.Items[0].Id; var repository = new SessionRepository(context); var round = repository.AddRoundToSessionItem(id); Assert.Equal(0, entity.Items[0].Rounds.ToList()[0].Votes.Count); var vote = new VoteCreateUpdateDTO { Estimate = 13, UserId = 42 }; repository.AddVoteToRound(vote, round.Id); Assert.Equal(1, entity.Items[0].Rounds.ToList()[0].Votes.Count); } }