Exemplo n.º 1
0
        public async Task GetAttachedOfFoundedAsync_Should_Attach()
        {
            var context  = _context.Context;
            var fixture  = new Fixture();
            var expected = fixture.Build <VideoItem>().Without(item => item.PlaylistVideoItems).Create();
            await context.Video.AddAsync(expected).ConfigureAwait(false);

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

            context.Entry(expected).State = EntityState.Detached;
            var videoItem = new VideoItem(expected.Id,
                                          expected.VideoIdentifier,
                                          expected.Title,
                                          expected.ThumbnailUrl,
                                          expected.DurationInSeconds);

            var actual = await _videoRepository.GetAttachedOfFoundedAsync(videoItem, context).ConfigureAwait(false);

            Assert.Equal(EntityState.Unchanged, context.Entry(actual).State);
        }