コード例 #1
0
        public async Task AddAsync_Should_Add_Duplicate()
        {
            var context  = _context.Context;
            var fixture  = new Fixture();
            var expected = fixture.Build <VideoItem>()
                           .Without(item => item.Id)
                           .Without(item => item.PlaylistVideoItems)
                           .Create();

            await _historyRepository.AddAsync(expected).ConfigureAwait(false);

            var videoItem = new VideoItem(expected.VideoIdentifier,
                                          expected.Title,
                                          expected.ThumbnailUrl,
                                          expected.DurationInSeconds);
            await _historyRepository.AddAsync(videoItem).ConfigureAwait(false);

            var histories  = context.History.ToArray();
            var videoItems = context.Video.ToArray();

            Assert.Single(videoItems);
            Assert.Equal(2, histories.Length);
            histories[0].Video.Should().BeEquivalentTo(expected);
            histories[1].Video.Should().BeEquivalentTo(expected);
        }
コード例 #2
0
        public async Task HistoryRepository_AddAsync_()
        {
            await using var context = new LibraryDbContext(UnitTestHelper.GetUnitTestDbOptions());

            var historyRepository = new HistoryRepository(context);
            var history           = new History {
                Id = 3
            };

            await historyRepository.AddAsync(history);

            await context.SaveChangesAsync();

            Assert.That(context.Histories.Count(), Is.EqualTo(3));
        }