예제 #1
0
        public async void InsertingEpisode_DataPassed_EpisodeInserted()
        {
            var builder = new DbContextOptionsBuilder();

            builder.UseInMemoryDatabase("InsertNewEpisode");

            using (var context = new StarWarsContext(builder.Options))
            {
                var repository = new EpisodeRepository(context);
                repository.CreateEpisode(new Episode()
                {
                    EpisodeName = "test episode"
                });
                await repository.SaveChangesAsync();
            };
            using (var context2 = new StarWarsContext(builder.Options))
            {
                Assert.Equal(1, context2.Episodes.Count());
            }
        }