Example #1
0
        public async Task FindAsync_given_existing_id_returns_mapped_EventStockDTO()
        {
            using (var connection = await CreateConnectionAsync())
                using (var context = await CreateContextAsync(connection))
                {
                    var entity = new EventStock
                    {
                        EventId  = 1,
                        PersonId = 1,
                        WineId   = 1
                    };

                    context.EventStocks.Add(entity);
                    await context.SaveChangesAsync();

                    var id = entity.Id;

                    var repository = new EventStockRepository(context);

                    var eventStock = await repository.FindAsync(id);

                    Assert.Equal(1, eventStock.EventId);
                    Assert.Equal(1, eventStock.PersonId);
                    Assert.Equal(1, eventStock.WineId);
                }
        }
Example #2
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 EventStockRepository(context);

                    var eventStock = await repository.FindAsync(42);

                    Assert.Null(eventStock);
                }
        }