public async Task BookRepository_DeleteByIdAsync_DeletesEntity()
        {
            await using var context = new LibraryDbContext(UnitTestHelper.GetUnitTestDbOptions());

            var historyRepository = new HistoryRepository(context);

            await historyRepository.DeleteByIdAsync(1);

            await context.SaveChangesAsync();

            Assert.That(context.Histories.Count(), Is.EqualTo(1));
        }
Ejemplo n.º 2
0
        public async Task DeleteByIdAsync_Should_Delete()
        {
            const int count        = 3;
            var       fixture      = new Fixture();
            var       historyItems = fixture.Build <HistoryItem>()
                                     .With(item => item.Video,
                                           fixture.Build <VideoItem>()
                                           .Without(item => item.PlaylistVideoItems)
                                           .Create())
                                     .CreateMany(count)
                                     .ToArray();
            var expected = historyItems.Skip(1).ToArray();
            var context  = _context.Context;
            await context.History.AddRangeAsync(expected).ConfigureAwait(false);

            await context.SaveChangesAsync().ConfigureAwait(false);

            await _historyRepository.DeleteByIdAsync(historyItems[0].Id).ConfigureAwait(false);

            var actual = context.History.ToArray();

            // ReSharper disable once CoVariantArrayConversion
            actual.Should().BeEquivalentTo(expected);
        }