コード例 #1
0
        public async void AddNewEpisode()
        {
            // Given
            var episode101 = new Episode {
                Id = 101, Title = "Episode101"
            };

            // When
            _episodeRepository.Add(episode101);
            var saved = await _episodeRepository.SaveChangesAsync();

            // Then
            Assert.True(saved);
            using (var db = new AmstramgramContext(_options, _dbLogger.Object))
            {
                var episode = await db.Episodes.FindAsync(101);

                Assert.NotNull(episode);
                Assert.Equal(101, episode.Id);
                Assert.Equal("Episode101", episode.Title);

                // Cleanup
                db.Episodes.Remove(episode);
                await db.SaveChangesAsync();
            }
        }