コード例 #1
0
        public void WillFlushSingleReduction()
        {
            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 key      = uriBuilder.ParseKey(url).RemoveDashes();

            new WebClient().DownloadData("http://localhost:8877/RRContent/" + key + "/flush");
            var cssFilesAfterFlush = Directory.GetFiles(rrFolder, "*.css");

            response = new WebClient().DownloadString("http://localhost:8877/Local.html");
            css      = cssPattern.Match(response).ToString();
            url      = urlPattern.Match(css).Groups["url"].Value;
            var newKey = uriBuilder.ParseKey(url);

            WaitToCreateResources(shouldBeNoExpiredFiles: true);
            var cssFilesAfterRefresh = Directory.GetFiles(rrFolder, "*.css");

            Assert.Equal(Guid.Empty, newKey);
            Assert.Equal(1, cssFilesAfterFlush.Length);
            Assert.True(cssFilesAfterFlush[0].Contains("-Expired-"));
            Assert.Equal(1, cssFilesAfterRefresh.Length);
            Assert.False(cssFilesAfterRefresh[0].Contains("-Expired-"));
        }
コード例 #2
0
        public void WillFlushSingleReduction()
        {
            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 oldKey       = uriBuilder.ParseKey(url).RemoveDashes();
            var fileName     = uriBuilder.ParseFileName(url);
            var firstCreated = File.GetLastWriteTime(rrFolder + "\\" + fileName);

            new WebClient().DownloadData("http://localhost:8877/RRContent/" + oldKey + "/flush");
            response = new WebClient().DownloadString("http://localhost:8877/Local.html");
            css      = cssPattern.Match(response).ToString();
            url      = urlPattern.Match(css).Groups["url"].Value;
            var newKey = uriBuilder.ParseKey(url);

            WaitToCreateResources();
            var secondCreated = File.GetLastWriteTime(rrFolder + "\\" + fileName);

            Assert.Equal(Guid.Empty, newKey);
            Assert.True(secondCreated > firstCreated);
        }
コード例 #3
0
            public void WillUseHashOfUrlsIfNoKeyIsGiven()
            {
                var testable = new TestableJavaScriptReducer();

                testable.Mock <IRRConfiguration>().Setup(x => x.SpriteVirtualPath).Returns("spritedir");
                var guid    = Hasher.Hash("http://host/js1.js::http://host/js2.js");
                var builder = new UriBuilder(testable.Mock <IRRConfiguration>().Object);

                var result = testable.ClassUnderTest.Process("http://host/js1.js::http://host/js2.js");

                Assert.Equal(guid, builder.ParseKey(result));
            }
コード例 #4
0
            public void WillReturnProcessedJsUrlWithKeyInPath()
            {
                var testable = new TestableJavaScriptReducer();

                testable.Mock <IRRConfiguration>().Setup(x => x.SpriteVirtualPath).Returns("spritedir");
                var guid    = Guid.NewGuid();
                var builder = new UriBuilder(testable.Mock <IRRConfiguration>().Object);

                var result = testable.ClassUnderTest.Process(guid, "http://host/js1.js::http://host/js2.js", string.Empty);

                Assert.Equal(guid, builder.ParseKey(result));
            }