Exemple #1
0
        public async Task UpdateAsync_given_non_existing_eventStock_returns_false()
        {
            using (var connection = await CreateConnectionAsync())
                using (var context = await CreateContextAsync(connection))
                {
                    var repository = new EventStockRepository(context);

                    var eventStock = new EventStockDTO {
                        Id = 42
                    };

                    var updated = await repository.UpdateAsync(eventStock);

                    Assert.False(updated);
                }
        }
Exemple #2
0
        public async Task UpdateAsync_given_eventStock_updates_it()
        {
            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 = new EventStockDTO
                    {
                        Id       = id,
                        EventId  = 2,
                        PersonId = 3,
                        WineId   = 4
                    };

                    var updated = await repository.UpdateAsync(eventStock);

                    Assert.True(updated);

                    var updatedEntity = await context.EventStocks.FindAsync(id);

                    Assert.Equal(2, updatedEntity.EventId);
                    Assert.Equal(3, updatedEntity.PersonId);
                    Assert.Equal(4, updatedEntity.WineId);
                }
        }