Esempio n. 1
0
        public void Check02DatabaseDataLinksOk()
        {
            using (var db = new SampleWebAppDb())
            {
                //SETUP
                DataLayerInitialise.InitialiseThis();
                var filepath = TestFileHelpers.GetTestFileFilePath("DbContentSimple.xml");

                //ATTEMPT
                DataLayerInitialise.ResetDatabaseToTestData(db, filepath);

                //VERIFY
                var allPosts = db.Posts.Include(x => x.Blogger).Include(x => x.Tags).ToList();
                allPosts[0].Blogger.Name.ShouldEqual("Fred Bloggs");
                string.Join(",", allPosts[0].Tags.Select(x => x.Slug)).ShouldEqual("ugly,bad");
                allPosts[1].Blogger.Name.ShouldEqual("Jon Smith");
                string.Join(",", allPosts[1].Tags.Select(x => x.Slug)).ShouldEqual("good,ugly");
                allPosts[2].Blogger.Name.ShouldEqual("Jon Smith");
                string.Join(",", allPosts[2].Tags.Select(x => x.Slug)).ShouldEqual("bad");

                db.PostTagGrades.Count().ShouldEqual(2);
                db.PostTagGrades.ToList().All(x => x.PostId == allPosts[0].PostId).ShouldEqual(true);
                string.Join(",", db.PostTagGrades.Include(x => x.TagPart).Select(x => x.TagPart.Slug)).ShouldEqual("bad,ugly");
            }
        }
 public void SetUpFixture()
 {
     using (var db = new SampleWebAppDb())
     {
         DataLayerInitialise.InitialiseThis();
         var filepath = TestFileHelpers.GetTestFileFilePath("DbContentSimple.xml");
         DataLayerInitialise.ResetDatabaseToTestData(db, filepath);
     }
 }
        public void TestCreateReadBundleFileCdnOk()
        {
            //SETUP

            //ATTEMPT
            var reader = new ReadBundleFile(TestFileHelpers.GetTestFileFilePath("BowerBundles02*.json"));

            //VERIFY
            CollectionAssert.AreEqual(new[] { "mainCss", "standardLibsJs", "appLibsJs", "jqueryval" }, reader.BundleNames);
        }
        public void TestReadBundleFileOk()
        {
            //SETUP

            //ATTEMPT
            using (new TimerToConsole("Read bundleFile"))
            {
                new ReadBundleFile(TestFileHelpers.GetTestFileFilePath("BowerBundles01*.json"));
            }
            //VERIFY
        }
        public void CheckReadDefaultConfigAndUserConfigOk()
        {
            //SETUP

            //ATTEMPT
            using (new TimerToConsole("Read default config and user config"))
            {
                ConfigInfo.ReadConfig(TestFileHelpers.GetTestFileFilePath("bundlerForBower02*.json"));
            }
            //VERIFY
        }
        public void TestGetBundleDebugFilesCndFileBundleListOk(string bundleName, params string[] expectedfiles)
        {
            //SETUP
            var reader = new ReadBundleFile(TestFileHelpers.GetTestFileFilePath("BowerBundles01*.json"));

            //ATTEMPT
            var files = reader.GetBundleDebugFiles(bundleName, "");

            //VERIFY
            CollectionAssert.AreEqual(expectedfiles, files);
        }
        public void TestGetBundleCdnInfoNonCdnOk()
        {
            //SETUP
            var reader = new ReadBundleFile(TestFileHelpers.GetTestFileFilePath("BowerBundles01*.json"));

            //ATTEMPT
            var cdns = reader.GetBundleCdnInfo("standardLibsJs");

            //VERIFY
            cdns.Count.ShouldEqual(0);
        }
        public void TestGetBundleDebugFilesBadCndFileBundleSingleOk()
        {
            //SETUP
            var reader = new ReadBundleFile(TestFileHelpers.GetTestFileFilePath("BowerBundles03*.json"));

            //ATTEMPT
            var ex = Assert.Throws <InvalidOperationException>(() => reader.GetBundleDebugFiles("missingDevelopmentJs"));

            //VERIFY
            ex.Message.ShouldEqual("The CDN bundle missingDevelopmentJs, array element 0, is missing a property called 'development'.");
        }
        public void CheckGetActualFilePathFromVirtualPathFileOk()
        {
            //SETUP
            var          func    = B4BSetupHelper.GetActualFilePathFromVirtualPath();
            const string relPath = "Scripts\\Script1.js";

            //ATTEMPT
            var path = func("~/" + relPath);

            //VERIFY
            path.ShouldEqual(TestFileHelpers.GetTestFileFilePath(relPath));
        }
        public void TestGetBundleDebugFilesNonCndFileBundleSingleOk(string bundleName, string expectedfile)
        {
            //SETUP
            var reader = new ReadBundleFile(TestFileHelpers.GetTestFileFilePath("BowerBundles01*.json"));

            //ATTEMPT
            var files = reader.GetBundleDebugFiles(bundleName, "").ToList();

            //VERIFY
            files.Count().ShouldEqual(1);
            files[0].ShouldEqual(expectedfile);
        }
Esempio n. 11
0
        public void FixtureSetup()
        {
            //This remembers the SqlErrorTextDict
            _rememberDefaultSqlErrorTextDict =
                GenericServicesConfig.SqlErrorDict.Select(x => new KeyValuePair <int, string>(x.Key, x.Value))
                .ToList();
            GenericServicesConfig.ClearSqlHandlerDict();

            using (var db = new SampleWebAppDb())
            {
                DataLayerInitialise.InitialiseThis();
                var filepath = TestFileHelpers.GetTestFileFilePath("DbContentSimple.xml");
                DataLayerInitialise.ResetDatabaseToTestData(db, filepath);
            }
        }
Esempio n. 12
0
        public void CheckReadConfigOverrideCssCndToNullOk()
        {
            //SETUP

            //ATTEMPT
            var config = ConfigInfo.ReadConfig(TestFileHelpers.GetTestFileFilePath("bundlerForBower02*.json"));

            //VERIFY
            config.ToString().ShouldEqual(
                "BundlesFileName: newName.json, StaticFileCaching: {fileUrl}?v={cachebuster}, JsDirectory: js/, " +
                "JsDebugHtmlFormatString: <script src='{fileUrl}'></script>, JsNonDebugHtmlFormatString: <script src='{fileUrl}?v={cachebuster}'></script>, " +
                "JsCdnHtmlFormatString: <script src='{cdnUrl}'></script><script>({cdnSuccessTest}||document.write(\"\\x3Cscript src='{fileUrl}?v={cachebuster}'\\x3C/script>\"));</script>, " +
                "CssDirectory: css/, " +
                "CssDebugHtmlFormatString: <link href='{fileUrl}' rel='stylesheet'/>, CssNonDebugHtmlFormatString: <link href='{fileUrl}?v={cachebuster}' rel='stylesheet'/>, " +
                "CssCdnHtmlFormatString: "
                );
        }
Esempio n. 13
0
        public void CheckReadConfigAspNetCore1ConfigOk()
        {
            //SETUP

            //ATTEMPT
            var config = ConfigInfo.ReadConfig(TestFileHelpers.GetTestFileFilePath("ASPNET Core 1 Config/bundlerForBower.json"));

            //VERIFY
            config.ToString().ShouldEqual(
                "BundlesFileName: AspNetCore1BowerBundles.json, StaticFileCaching: , JsDirectory: wwwroot/js/, " +
                "JsDebugHtmlFormatString: <script src='{fileUrl}'></script>, JsNonDebugHtmlFormatString: <script src=\"{fileUrl}\" asp-append-version=\"true\"></script>, " +
                "JsCdnHtmlFormatString: <script src='{cdnUrl}' asp-fallback-src='{fileUrl}' asp-fallback-test='{cdnSuccessTest}'></script>, " +
                "CssDirectory: wwwroot/css/, " +
                "CssDebugHtmlFormatString: <link href='{fileUrl}' rel='stylesheet'/>, " +
                "CssNonDebugHtmlFormatString: <link href=\"{fileUrl}\" asp-append-version=\"true\" rel=\"stylesheet\"/>, " +
                "CssCdnHtmlFormatString: <link rel=\"stylesheet\" href='{cdnUrl}' asp-fallback-href='{fileUrl}' asp-fallback-test-class=\"{testClass}\" asp-fallback-test-property=\"{testProperty}\" asp-fallback-test-value=\"{testValue}\" />"
                );
        }
Esempio n. 14
0
        public void Check10DatabaseResetWithIGenericServicesDbContextOk()
        {
            using (var db = new SampleWebAppDb() as IGenericServicesDbContext)
            {
                //SETUP
                DataLayerInitialise.InitialiseThis();
                var filepath = TestFileHelpers.GetTestFileFilePath("DbContentSimple.xml");

                //ATTEMPT
                DataLayerInitialise.ResetDatabaseToTestData(db as SampleWebAppDb, filepath);

                //VERIFY
                db.Set <Blog>().Count().ShouldEqual(2);
                db.Set <Post>().Count().ShouldEqual(3);
                db.Set <Tag>().Count().ShouldEqual(3);
                db.Set <PostTagGrade>().Count().ShouldEqual(2);
            }
        }
Esempio n. 15
0
        public void Check01DatabaseResetOk()
        {
            using (var db = new SampleWebAppDb())
            {
                //SETUP
                DataLayerInitialise.InitialiseThis();
                var filepath = TestFileHelpers.GetTestFileFilePath("DbContentSimple.xml");

                //ATTEMPT
                DataLayerInitialise.ResetDatabaseToTestData(db, filepath);

                //VERIFY
                db.Blogs.Count().ShouldEqual(2);
                db.Posts.Count().ShouldEqual(3);
                db.Tags.Count().ShouldEqual(3);
                db.Database.SqlQuery <int>("SELECT COUNT(*) FROM dbo.TagPosts").First().ShouldEqual(5);
                db.PostTagGrades.Count().ShouldEqual(2);
            }
        }
        public void TestGetBundleCdnInfoCdnOk()
        {
            //SETUP
            var reader = new ReadBundleFile(TestFileHelpers.GetTestFileFilePath("BowerBundles02*.json"));

            //ATTEMPT
            var cdns = reader.GetBundleCdnInfo("standardLibsJs").ToList();

            //VERIFY
            cdns.Count.ShouldEqual(2);
            var i = 0;

            cdns[i++].ToString().ShouldEqual("Development: jquery.js, Production: jquery.min.js, " +
                                             "cdnUrl: https://ajax.aspnetcdn.com/ajax/jquery/jquery-2.1.4.min.js, cdnSuccessTest: window.jQuery");
            cdns[i++].ToString().ShouldEqual("Development: bootstrap.js, Production: bootstrap.min.js, " +
                                             "cdnUrl: https://ajax.aspnetcdn.com/ajax/bootstrap/3.3.5/bootstrap.min.js, cdnSuccessTest: window.jQuery && window.jQuery.fn && window.jQuery.fn.modal");
            //foreach (var cdnInfo in cdns)
            //{
            //    Console.WriteLine("cdns[i++].ToString().ShouldEqual(\"{0}\");", cdnInfo);
            //}
        }