public async Task UpdateAsync_given_vote_updates_it() { using (var connection = await CreateConnectionAsync()) using (var context = await CreateContextAsync(connection)) { var entity = new Vote { EventStockId = 1, Score = 5 }; context.Votes.Add(entity); await context.SaveChangesAsync(); var id = entity.Id; var repository = new VoteRepository(context); var vote = new VoteDTO { Id = id, EventStockId = 1, Score = 4 }; var updated = await repository.UpdateAsync(vote); Assert.True(updated); var updatedEntity = await context.Votes.FindAsync(id); Assert.Equal(1, updatedEntity.EventStockId); Assert.Equal(4, updatedEntity.Score); } }
public async Task UpdateAsync_given_non_existing_vote_returns_false() { using (var connection = await CreateConnectionAsync()) using (var context = await CreateContextAsync(connection)) { var repository = new VoteRepository(context); var vote = new VoteDTO { Id = 42 }; var updated = await repository.UpdateAsync(vote); Assert.False(updated); } }