Ejemplo n.º 1
0
        public async Task FindAsync_given_non_existing_id_returns_null()
        {
            using (var connection = await CreateConnectionAsync())
                using (var context = await CreateContextAsync(connection))
                {
                    var repository = new VoteRepository(context);

                    var vote = await repository.FindAsync(42);

                    Assert.Null(vote);
                }
        }
Ejemplo n.º 2
0
        public async Task FindAsync_given_existing_id_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 vote = await repository.FindAsync(id);

                    Assert.Equal(1, vote.EventStockId);
                    Assert.Equal(5, vote.Score);
                }
        }