Beispiel #1
0
        public void GivenScssThatImportsOtherScssFile_WhenCompile_ThenReferencedFilesContainsBothPaths()
        {
            var compiler = new SassCompiler();

            var file = new Mock<IFile>();
            var other = new Mock<IFile>();
            var directory = new Mock<IDirectory>();
            other.SetupGet(f => f.Exists).Returns(true);
            other.Setup(f => f.Open(It.IsAny<FileMode>(), It.IsAny<FileAccess>(), It.IsAny<FileShare>()))
                .Returns(() => "p { color: red; }".AsStream());
            directory.Setup(d => d.GetFile(It.IsAny<string>()))
                .Returns(new NonExistentFile("~"));
            directory.Setup(d => d.GetFile("other.scss"))
                .Returns(other.Object);
            file.SetupGet(f => f.FullPath).Returns("~/test.scss");
            file.SetupGet(f => f.Directory).Returns(directory.Object);

            compiler.Compile("@import \"other.scss\";", file.Object);

            compiler.ReferencedFiles.ToArray().ShouldEqual(new[]
            {
                "~/test.scss",
                "./other.scss"
            });
        }
Beispiel #2
0
        public void GivenScssThatImportsOtherScssFile_WhenCompile_ThenReferencedFilesContainsBothPaths()
        {
            var compiler = new SassCompiler();

            var file      = new Mock <IFile>();
            var other     = new Mock <IFile>();
            var directory = new Mock <IDirectory>();

            other.SetupGet(f => f.Exists).Returns(true);
            other.Setup(f => f.Open(It.IsAny <FileMode>(), It.IsAny <FileAccess>(), It.IsAny <FileShare>()))
            .Returns(() => "p { color: red; }".AsStream());
            directory.Setup(d => d.GetFile(It.IsAny <string>()))
            .Returns(new NonExistentFile("~"));
            directory.Setup(d => d.GetFile("other.scss"))
            .Returns(other.Object);
            file.SetupGet(f => f.FullPath).Returns("~/test.scss");
            file.SetupGet(f => f.Directory).Returns(directory.Object);

            compiler.Compile("@import \"other.scss\";", file.Object);

            compiler.ReferencedFiles.ToArray().ShouldEqual(new[]
            {
                "~/test.scss",
                "./other.scss"
            });
        }
Beispiel #3
0
        public void WhenCompileScss_ThenReturnCss()
        {
            var compiler = new SassCompiler();
            var file = new Mock<IFile>();
            file.SetupGet(f => f.FullPath).Returns("~/test.scss");

            var css = compiler.Compile("$x: red; p { color: $x; }", file.Object);

            css.ShouldEqual("p {\n  color: red; }\n");
        }
Beispiel #4
0
        public void WhenCompileScss_ThenReferencedFilesContainsTheSourceFile()
        {
            var compiler = new SassCompiler();
            var file = new Mock<IFile>();
            file.SetupGet(f => f.FullPath).Returns("~/test.scss");

            compiler.Compile("$x: red; p { color: $x; }", file.Object);

            compiler.ReferencedFiles.ShouldEqual(new[] { "~/test.scss" });
        }
Beispiel #5
0
        public void WhenCompileScss_ThenReferencedFilesContainsTheSourceFile()
        {
            var compiler = new SassCompiler();
            var file     = new Mock <IFile>();

            file.SetupGet(f => f.FullPath).Returns("~/test.scss");

            compiler.Compile("$x: red; p { color: $x; }", file.Object);

            compiler.ReferencedFiles.ShouldEqual(new[] { "~/test.scss" });
        }
Beispiel #6
0
        public void WhenCompileScss_ThenReturnCss()
        {
            var compiler = new SassCompiler();
            var file     = new Mock <IFile>();

            file.SetupGet(f => f.FullPath).Returns("~/test.scss");

            var css = compiler.Compile("$x: red; p { color: $x; }", file.Object);

            css.ShouldEqual("p {\n  color: red; }\n");
        }
Beispiel #7
0
        public SassCompiler_Tests()
        {
            directory = new Mock<IDirectory>();
            file = new Mock<IFile>();
            directory.Setup(d => d.GetFile(It.IsAny<string>())).Returns(new NonExistentFile("~"));
            directory.Setup(d => d.GetFile("~/test.scss")).Returns(file.Object);
            file.SetupGet(f => f.FullPath).Returns("~/test.scss");
            file.SetupGet(f => f.Directory).Returns(directory.Object);

            compileContext = new CompileContext { RootDirectory = directory.Object, SourceFilePath = "~/test.scss" };
            compiler = new SassCompiler();
        }
Beispiel #8
0
        public SassCompiler_Tests()
        {
            directory = new Mock <IDirectory>();
            file      = new Mock <IFile>();
            directory.Setup(d => d.GetFile(It.IsAny <string>())).Returns(new NonExistentFile("~"));
            directory.Setup(d => d.GetFile("~/test.scss")).Returns(file.Object);
            file.SetupGet(f => f.FullPath).Returns("~/test.scss");
            file.SetupGet(f => f.Directory).Returns(directory.Object);

            compileContext = new CompileContext {
                RootDirectory = directory.Object, SourceFilePath = "~/test.scss"
            };
            compiler = new SassCompiler();
        }