Esempio n. 1
0
        public void TestLoadBooksOk()
        {
            //SETUP
            var callingAssemblyPath = TestData.GetCallingAssemblyTopLevelDir();
            var fileDir             = Path.Combine(TestData.GetTestDataDir(), "seedData\\");
            var loader = new ManningBookLoad(fileDir, "ManningBooks*.json", "ManningDetails*.json");

            //ATTEMPT
            var loadedBooks = loader.LoadBooks(false);

            //VERIFY
            loadedBooks.Count().ShouldEqual(6);
        }
Esempio n. 2
0
        public void TestLoadBooksFromTestDataOk()
        {
            //SETUP
            var fileDir = Path.Combine(TestData.GetTestDataDir(), "seedData\\");
            var loader  = new ManningBookLoad(fileDir, "ManningBooks*.json", "ManningDetails*.json");

            //ATTEMPT
            var loadedBooks = loader.LoadBooks(true).ToList();

            //VERIFY
            loadedBooks.Count().ShouldEqual(6);
            loadedBooks.Count(x => x.Details?.Description != null).ShouldEqual(0);
            loadedBooks.All(x => x.Tags.Select(x => x.TagId).Contains("Manning books")).ShouldBeTrue();
        }
Esempio n. 3
0
        public void TestLoadBooksCheckTagsOk(bool tagAsOriginal)
        {
            //SETUP
            var callingAssemblyPath = TestData.GetCallingAssemblyTopLevelDir();
            var fileDir             = Path.Combine(TestData.GetTestDataDir(), "seedData\\");
            var loader = new ManningBookLoad(fileDir, "ManningBooks*.json", "ManningDetails*.json");

            //ATTEMPT
            var loadedBooks = loader.LoadBooks(tagAsOriginal);

            //VERIFY
            foreach (var book in loadedBooks)
            {
                book.Tags.Any().ShouldBeTrue();
                book.Tags.Select(x => x.TagId).Contains("Manning books").ShouldEqual(tagAsOriginal);
            }
        }
Esempio n. 4
0
        public void TestLoadBooksAddTenToDatabaseOk()
        {
            //SETUP
            var options = SqliteInMemory.CreateOptions <BookDbContext>();

            using var context = new BookDbContext(options);
            context.Database.EnsureCreated();

            var callingAssemblyPath = TestData.GetCallingAssemblyTopLevelDir();
            var fileDir             = Path.Combine(TestData.GetTestDataDir(), "seedData\\");

            var loader = new ManningBookLoad(fileDir, "ManningBooks*.json", "ManningDetails*.json");

            //ATTEMPT
            context.AddRange(loader.LoadBooks(false));
            context.SaveChanges();

            //VERIFY
            context.Books.Count().ShouldEqual(6);
            context.Authors.Count().ShouldEqual(8);
            context.Tags.Count().ShouldEqual(5);
        }