コード例 #1
0
        public void CanUseRelativePathsInImportStatements()
        {
            string inputFilename1 = "~/content/parent.less";
            string inputFilename2 = "~/content/child.less";

            var pathProvider = new InMemoryVirtualPathProvider()
                .AddFile(inputFilename1, "@import \"child.less\";")
                .AddFile(inputFilename2, ".selector { background: yellow; }");
            SetUpPathProvider(pathProvider);

            var bundle = new LessBundle("~/output/relative-paths.css")
                .Include(inputFilename1);
            var bundleResponse = bundle.GenerateBundleResponse(CreateBundleContext(bundle));

            Assert.That(bundleResponse.Content, Is.EqualTo(".selector {\n  background: yellow;\n}\n"));
        }
コード例 #2
0
        public void IncludedFilesRunInTheSameScope()
        {
            string inputFilename1 = "~/content/variable.less";
            string inputFilename2 = "~/content/selector.less";

            var pathProvider = new InMemoryVirtualPathProvider()
                .AddFile(inputFilename1, "@nice-blue: #5B83AD;")
                .AddFile(inputFilename2, ".selector { background: @nice-blue; }");
            SetUpPathProvider(pathProvider);

            var bundle = new LessBundle("~/output/same-scope.css")
                .Include(inputFilename1)
                .Include(inputFilename2);
            var bundleResponse = bundle.GenerateBundleResponse(CreateBundleContext(bundle));

            Assert.That(bundleResponse.Content, Is.EqualTo(".selector {\n  background: #5b83ad;\n}\n"));
        }
コード例 #3
0
        public void NestedRelativeImportsAreRelativeToTheCurrentFile()
        {
            string inputFilename1 = "~/content/relative-parent.less";
            string inputFilename2 = "~/content/project/child.less";
            string inputFilename3 = "~/content/project/sub/grandchild.less";

            var pathProvider = new InMemoryVirtualPathProvider()
                .AddFile(inputFilename1, "@import \"project/child.less\";")
                .AddFile(inputFilename2, "@import \"sub/grandchild.less\";")
                .AddFile(inputFilename3, ".selector { background: yellow; }");
            SetUpPathProvider(pathProvider);

            var bundle = new LessBundle("~/output/relative-paths.css")
                .Include(inputFilename1);
            var bundleResponse = bundle.GenerateBundleResponse(CreateBundleContext(bundle));

            Assert.That(bundleResponse.Content, Is.EqualTo(".selector {\n  background: yellow;\n}\n"));
        }
コード例 #4
0
        public void ShowParsingErrorsInBundleResponse()
        {
            string inputFilename = "~/content/error.less";
            var pathProvider = new InMemoryVirtualPathProvider(inputFilename, ".button { background: blue;");
            SetUpPathProvider(pathProvider);

            var bundle = new LessBundle("~/output/error.css")
                .Include(inputFilename);
            var bundleResponse = bundle.GenerateBundleResponse(CreateBundleContext(bundle));

            Assert.That(bundleResponse.Content, Is.StringStarting("Missing closing '}' on line 1 in file '~/content/error.less':"));
        }
コード例 #5
0
        public void UsesDotLessConfigurationFromWebConfig()
        {
            string inputFilename = "~/content/minified.less";
            var pathProvider = new InMemoryVirtualPathProvider(inputFilename, ".button { background: blue;}");
            SetUpPathProvider(pathProvider);
            Config.MinifyOutput = true;

            var bundle = new LessBundle("~/output/minified.css")
                .Include(inputFilename);
            var bundleResponse = bundle.GenerateBundleResponse(CreateBundleContext(bundle));

            Assert.That(bundleResponse.Content, Is.EqualTo(".button{background:blue}"));
        }
コード例 #6
0
        public void TransformFilesToLess()
        {
            string inputFilename1 = "~/content/file1.less";
            string inputFilename2 = "~/content/file2.less";

            var pathProvider = new InMemoryVirtualPathProvider()
                .AddFile(inputFilename1, "body { width: 1+1px; }")
                .AddFile(inputFilename2, "h1 { font-size: 3*16em; }");
            SetUpPathProvider(pathProvider);

            var bundle = new LessBundle("~/Content/file.css")
                .Include(inputFilename1)
                .Include(inputFilename2);
            var bundleResponse = bundle.GenerateBundleResponse(CreateBundleContext(bundle));

            Assert.That(bundleResponse.ContentType, Is.EqualTo("text/css"));
            Assert.That(bundleResponse.Content, Is.EqualTo("body {\n  width: 2px;\n}\nh1 {\n  font-size: 48em;\n}\n"));
        }