Exemplo n.º 1
0
        public async Task TestSeedDatabaseIfNoBooksAsyncEmptyDatabase()
        {
            //SETUP
            var options = this.CreateUniqueClassOptions <EfCoreContext>();

            using (var context = new EfCoreContext(options))
            {
                context.Database.EnsureClean();

                var callingAssemblyPath = TestData.GetCallingAssemblyTopLevelDir();
                var wwwrootDir          = Path.GetFullPath(Path.Combine(callingAssemblyPath, "..\\BookApp\\wwwroot"));

                //ATTEMPT
                await context.SeedDatabaseIfNoBooksAsync(wwwrootDir);

                //VERIFY
                context.Books.Count().ShouldEqual(54);
            }
        }
Exemplo n.º 2
0
        public async Task TestSeedDatabaseIfNoBooksAsyncBooksAlreadyThere()
        {
            //SETUP
            var options = SqliteInMemory.CreateOptions <EfCoreContext>();

            using (var context = new EfCoreContext(options))
            {
                context.Database.EnsureCreated();
                context.SeedDatabaseFourBooks();

                var callingAssemblyPath = TestData.GetCallingAssemblyTopLevelDir();
                var wwwrootDir          = Path.GetFullPath(Path.Combine(callingAssemblyPath, "..\\BookApp\\wwwroot"));

                //ATTEMPT
                await context.SeedDatabaseIfNoBooksAsync(wwwrootDir);

                //VERIFY
                context.Books.Count().ShouldEqual(4);
            }
        }