예제 #1
0
파일: Asset.cs 프로젝트: romanych/cassette
        public Asset_CreateCacheManifest_Tests()
        {
            root = Directory.CreateDirectory(Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString()));
            root.CreateSubdirectory("module");
            filename = Path.Combine(root.FullName, "module", "test.js");
            // Write some testable content to the file.
            File.WriteAllText(filename, "asset content");
            var fileSystem = new FileSystemDirectory(root.FullName);

            var module = new Module("~/module");
            asset = new Asset("~/module/test.js", module, fileSystem.GetFile("module\\test.js"));
            module.Assets.Add(asset);

            File.WriteAllText(Path.Combine(root.FullName, "module", "another.js"), "");
            var another = new Asset("~/module/another.js", module, fileSystem.GetFile("module\\another.js"));
            module.Assets.Add(another);
        }
예제 #2
0
 public void GivenSubDirectoryDoesNotExist_WhenGetFile_ThenReturnNonExistentFile()
 {
     using (var path = new TempDirectory())
     {
         var dir  = new FileSystemDirectory(path);
         var file = dir.GetFile("sub\\test.txt");
         file.ShouldBeType <NonExistentFile>();
     }
 }
예제 #3
0
 public void GivenFileDoesNotExist_WhenGetFile_ThenReturnFileSystemFile()
 {
     using (var path = new TempDirectory())
     {
         var dir = new FileSystemDirectory(path);
         var file = dir.GetFile("test.txt");
         file.ShouldBeType<FileSystemFile>();
     }
 }
예제 #4
0
 public void GivenFileDoesNotExist_WhenGetFile_ThenReturnFileSystemFileThatDoesNotExist()
 {
     using (var path = new TempDirectory())
     {
         var dir  = new FileSystemDirectory(path);
         var file = dir.GetFile("test.txt");
         file.ShouldBeType <FileSystemFile>();
         file.Exists.ShouldBeFalse();
     }
 }
예제 #5
0
        public void GivenFileExists_WhenGetFile_ThenReturnFileSystemFile()
        {
            using (var path = new TempDirectory())
            {
                File.WriteAllText(Path.Combine(path, "test.txt"), "");

                var dir  = new FileSystemDirectory(path);
                var file = dir.GetFile("test.txt");
                file.ShouldBeType <FileSystemFile>();
                PathUtilities.PathsEqual(file.FullPath, "~/test.txt").ShouldBeTrue();
            }
        }
예제 #6
0
 public void GivenSubDirectoryDoesNotExist_WhenGetFile_ThenReturnNonExistentFile()
 {
     using (var path = new TempDirectory())
     {
         var dir = new FileSystemDirectory(path);
         var file = dir.GetFile("sub\\test.txt");
         file.Exists.ShouldBeFalse();
     }
 }
예제 #7
0
        public void GivenFileExists_WhenGetFile_ThenReturnFileSystemFile()
        {
            using (var path = new TempDirectory())
            {
                File.WriteAllText(Path.Combine(path, "test.txt"), "");

                var dir = new FileSystemDirectory(path);
                var file = dir.GetFile("test.txt");
                file.ShouldBeType<FileSystemFile>();
                PathUtilities.PathsEqual(file.FullPath, "~/test.txt").ShouldBeTrue();
            }
        }
예제 #8
0
        public void Variable_defined_by_nested_import_is_replaced_in_CSS_output()
        {
            using (var path = new TempDirectory())
            {
                File.WriteAllText(Path.Combine(path, "main.less"), "@import 'first.less';\np { color: @c }");
                File.WriteAllText(Path.Combine(path, "first.less"), "@import 'second.less';");
                File.WriteAllText(Path.Combine(path, "second.less"), "@c: red;");
                var directory = new FileSystemDirectory(path);
                var file = directory.GetFile("main.less");

                compileContext.RootDirectory = directory;
                compileContext.SourceFilePath = "~/main.less";
                var css = compiler.Compile(file.OpenRead().ReadToEnd(), compileContext);

                css.Output.ShouldContain("color: red;");
            }
        }