예제 #1
0
        public SqlServerStoreFacts()
        {
            var dataDir = Directory.GetParent(Directory.GetCurrentDirectory()).Parent.Parent.FullName +
                          "\\RequestReduce.SampleWeb\\App_Data";

            if (Directory.Exists(dataDir))
            {
                File.Delete(dataDir + "\\RequestReduce.sdf");
            }
            else
            {
                Directory.CreateDirectory(dataDir);
            }

            RequestReduceDB.DefaultProviderName = "System.Data.SQLite";
            var mockConfig = new Mock <IRRConfiguration>();

            mockConfig.Setup(x => x.ConnectionStringName).Returns("data source=" + dataDir + "\\RequestReduce.sdf;Version=3;");
            config = mockConfig.Object;
            repo   = new FileRepository(config);
            IntegrationFactHelper.RecyclePool();
            repo.GetDatabase().Execute(SqliteHelper.GetSqlLightSafeSql());
            rrFolder   = IntegrationFactHelper.ResetPhysicalContentDirectoryAndConfigureStore(Configuration.Store.SqlServerStore, 3000);
            uriBuilder = new UriBuilder(config);
        }
예제 #2
0
        public void WillUseSameReductionAfterAppPoolRecycle()
        {
            var urlPattern = new Regex(@"(href|src)=""?(?<url>[^"" ]+)""?[^ />]+[ />]", RegexOptions.IgnoreCase);

            new WebClient().DownloadString("http://localhost:8877/Local.html");
            WaitToCreateResources();
            var response   = new WebClient().DownloadString("http://localhost:8877/Local.html");
            var css        = new CssResource().ResourceRegex.Match(response).ToString();
            var js         = new JavaScriptResource().ResourceRegex.Match(response).ToString();
            var urls       = new string[] { urlPattern.Match(css).Groups["url"].Value, urlPattern.Match(js).Groups["url"].Value };
            var files      = new string [] { urls[0].Replace("/RRContent", rrFolder).Replace("/", "\\"), urls[1].Replace("/RRContent", rrFolder).Replace("/", "\\") };
            var createTime = new DateTime[] { new FileInfo(files[0]).LastWriteTime, new FileInfo(files[1]).LastWriteTime };

            IntegrationFactHelper.RecyclePool();
            new WebClient().DownloadString("http://localhost:8877/Local.html");
            WaitToCreateResources();

            Assert.Equal(createTime[0], new FileInfo(files[0]).LastWriteTime);
            Assert.Equal(createTime[1], new FileInfo(files[1]).LastWriteTime);
        }
예제 #3
0
        public void WillReduceToOneCssAndScripOnNet35FullTrust()
        {
            if (Directory.Exists(rrFolder))
            {
                Directory.Delete(rrFolder, true);
            }

            IntegrationFactHelper.SetSampleWeb35StoreAndTrust(Configuration.Store.SqlServerStore, 3000, "Full");

            new WebClient().DownloadString("http://localhost:8878/sqlcehosting.aspx");

            new WebClient().DownloadString("http://localhost:8878/Local.html");
            WaitToCreateResources(expectedJsFiles: 1);

            var response = new WebClient().DownloadString("http://localhost:8878/Local.html");

            Assert.Equal(1, new CssResource().ResourceRegex.Matches(response).Count);
            Assert.Equal(1, new JavaScriptResource().ResourceRegex.Matches(response).Count);
            IntegrationFactHelper.SetSampleWeb35StoreAndTrust(Configuration.Store.LocalDiskStore, Timeout.Infinite, "Medium");
        }
예제 #4
0
        public void WillReduceToOneCssSpriteAndScriptInHeadOnNet35MediumTrust()
        {
            var rrFolderOld = rrFolder;

            rrFolder = rrFolder.Replace("SampleWeb", "SampleWeb35");
            if (Directory.Exists(rrFolder))
            {
                Directory.Delete(rrFolder, true);
            }
            IntegrationFactHelper.SetSampleWeb35StoreAndTrust(Configuration.Store.LocalDiskStore, Timeout.Infinite, "Medium");

            new WebClient().DownloadString("http://localhost:8878/Local.html");
            WaitToCreateResources(1, 1, false, 30000);

            var response = new WebClient().DownloadString("http://localhost:8878/Local.html");

            Assert.Contains("RequestReduce", new CssResource().ResourceRegex.Match(response).ToString());
            Assert.Contains("RequestReduce", new JavaScriptResource().ResourceRegex.Match(response).ToString());
            Assert.Equal(1, Directory.GetFiles(rrFolder, "*.png").Count());
            rrFolder = rrFolderOld;
        }
        public SqlServerStoreFacts()
        {
            var dataDir = Directory.GetParent(Directory.GetCurrentDirectory()).Parent.Parent.FullName +
                          "\\RequestReduce.SampleWeb\\App_Data";

            if (!Directory.Exists(dataDir))
            {
                Directory.CreateDirectory(dataDir);
            }
            Database.DefaultConnectionFactory = new SqlCeConnectionFactory("System.Data.SqlServerCe.4.0");
            var mockConfig = new Mock <IRRConfiguration>();

            mockConfig.Setup(x => x.ConnectionStringName).Returns("data source=" + dataDir + "\\RequestReduce.sdf");
            config = mockConfig.Object;
            repo   = new FileRepository(config);
            IntegrationFactHelper.RecyclePool();
            repo.Context.Database.Delete();
            repo.Context.Database.Create();
            rrFolder   = IntegrationFactHelper.ResetPhysicalContentDirectoryAndConfigureStore(Configuration.Store.SqlServerStore, 3000);
            uriBuilder = new UriBuilder(config);
        }
예제 #6
0
        public void WillReReduceAfterFileIsRemovedFromDb()
        {
            var cssPattern = new Regex(@"<link[^>]+type=""?text/css""?[^>]+>", RegexOptions.IgnoreCase);
            var urlPattern = new Regex(@"href=""?(?<url>[^"" ]+)""?[^ />]+[ />]", RegexOptions.IgnoreCase);

            new WebClient().DownloadString("http://localhost:8877/Local.html");
            WaitToCreateResources();
            var response   = new WebClient().DownloadString("http://localhost:8877/Local.html");
            var css        = cssPattern.Match(response).ToString();
            var url        = urlPattern.Match(css).Groups["url"].Value;
            var id         = Hasher.Hash(uriBuilder.ParseFileName(url));
            var createTime = repo.SingleOrDefault <RequestReduceFile>(id).LastUpdated;

            repo.Delete <RequestReduceFile>(id);
            IntegrationFactHelper.RecyclePool();
            new WebClient().DownloadString("http://localhost:8877/Local.html");
            WaitToCreateResources();
            new WebClient().DownloadString("http://localhost:8877/Local.html");

            Assert.True(createTime < repo.SingleOrDefault <RequestReduceFile>(id).LastUpdated);
        }
예제 #7
0
 public ModuleFacts()
 {
     rrFolder   = IntegrationFactHelper.ResetPhysicalContentDirectoryAndConfigureStore(Configuration.Store.LocalDiskStore, Timeout.Infinite);
     uriBuilder = new UriBuilder(new Mock <IRRConfiguration>().Object);
 }
 public void Dispose()
 {
     IntegrationFactHelper.ResetPhysicalContentDirectoryAndConfigureStore(Configuration.Store.LocalDiskStore, Timeout.Infinite);
 }