Exemple #1
0
        private static void SetupForTestExplorerMode()
        {
            InitAppSettings();
            var config = TestRunConfigLoader.LoadForTestExplorer(AppSettings);

            Reset(config);
            SqlCacheLogHelper.SetupSqlCacheLog();
        }
Exemple #2
0
        public void TestSqlCache()
        {
            Startup.BooksApp.LogTestStart();

            var app     = Startup.BooksApp;
            var session = app.OpenSession();
            var books   = session.EntitySet <IBook>();
            var authors = session.EntitySet <IAuthor>();

            //Testing how expr like 'where someEnt.OtherEnt == null' are handled
            var qa = from a in authors
                     where a.User == null
                     select a;
            var aList = qa.ToList(); // just checking SQL is correct and it runs


            //test compiled query caching
            var kidBooksQ = from b in books
                            where b.Publisher.Name == "Kids Books"
                            orderby b.Title
                            select b;

            var lkpCount0    = SqlCache.LookupCount;
            var missCount    = SqlCache.MissCount;
            var kidBooksList = kidBooksQ.ToList();

            Assert.IsTrue(kidBooksList.Count > 0, "kid books not found.");
            Assert.AreEqual(lkpCount0 + 1, SqlCache.LookupCount, "Expected one failed sql cache lookup");
            Assert.AreEqual(missCount + 1, SqlCache.MissCount, "Expected one failed sql cache lookup");
            //do it  2 more times
            kidBooksList = kidBooksQ.ToList();
            kidBooksList = kidBooksQ.ToList();
            Assert.IsTrue(kidBooksList.Count > 0, "kid books not found.");
            Assert.AreEqual(lkpCount0 + 3, SqlCache.LookupCount, "Expected 2 more lookup");
            Assert.AreEqual(missCount + 1, SqlCache.MissCount, "Expected no more misses");

            // Query with disabled compiled query cache. Disable cache for 'search' queries, to avoid polluting cache
            // with many custom searches that users enter in search form.
            // Note about the test query - we must make sure it is of unique shape, otherwise system will pickup previously compiled query.
            var noCacheBooksQ = session.EntitySet <IBook>().WithOptions(QueryOptions.NoQueryCache);
            var kidBooksQDesc = from b in noCacheBooksQ
                                where b.Publisher.Name == "Kids Books"
                                orderby b.Title descending
                                select b;
            var kidBooksListDesc = kidBooksQ.ToList();

            Assert.IsTrue(kidBooksListDesc.Count > 0, "Query with disabled query cache failed: multiple-author books not found.");
            kidBooksListDesc = kidBooksQ.ToList();

            SqlCacheLogHelper.FlushSqlCacheLog();
        }
Exemple #3
0
        public static void TearDown()
        {
            //You should do this normally - shutdown the entity store
            // but in this test app it would take too long time for all tests (re-init database for each test class)
            // so by default running without it
#if FULL_SHUTDOWN
            if (BooksApp != null)
            {
                BooksApp.Shutdown();
            }
            BooksApp = null;
#endif
            if (BooksApp != null)
            {
                BooksApp.Flush();
            }
            SqlCacheLogHelper.FlushSqlCacheLog();
            Thread.Sleep(200);
        }