示例#1
0
        public async Task Read_returns_mapped_VoteDTO()
        {
            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 votes = await repository.ReadAsync();

                    var vote = votes.FirstOrDefault();
                    Assert.Equal(1, votes.Count);
                    Assert.Equal(entity.EventStockId, vote.EventStockId);
                    Assert.Equal(entity.Score, vote.Score);
                }
        }