Example #1
0
        public void TransformAddsRawReferenceForImportedFilePaths()
        {
            var asset = new Mock<IAsset>();
            var compiler = new Mock<ICompiler>();

            compiler
                .Setup(c => c.Compile(It.IsAny<string>(), It.IsAny<CompileContext>()))
                .Returns(new CompileResult("", new[] { "~/imported.less" }));

            var transformer = new CompileAsset(compiler.Object, Mock.Of<IDirectory>());
            var getResultStream = transformer.Transform(() => Stream.Null, asset.Object);
            getResultStream();

            asset.Verify(a => a.AddRawFileReference("~/imported.less"));
        }
Example #2
0
        public void TransformAddsRawReferenceForImportedFilePaths()
        {
            var asset    = new Mock <IAsset>();
            var compiler = new Mock <ICompiler>();

            compiler
            .Setup(c => c.Compile(It.IsAny <string>(), It.IsAny <CompileContext>()))
            .Returns(new CompileResult("", new[] { "~/imported.less" }));

            var transformer     = new CompileAsset(compiler.Object, Mock.Of <IDirectory>());
            var getResultStream = transformer.Transform(() => Stream.Null, asset.Object);

            getResultStream();

            asset.Verify(a => a.AddRawFileReference("~/imported.less"));
        }
Example #3
0
        public void TransformCallsLessCompiler()
        {
            var asset = new Mock<IAsset>();
            asset.SetupGet(a => a.SourceFile.FullPath).Returns("test.less");

            var sourceInput = "source-input";
            var compilerOutput = "compiler-output";
            var compiler = StubCompiler(sourceInput, compilerOutput);

            var transformer = new CompileAsset(compiler);

            var getResultStream = transformer.Transform(
                () => sourceInput.AsStream(),
                asset.Object
            );

            using (var reader = new StreamReader(getResultStream()))
            {
                reader.ReadToEnd().ShouldEqual(compilerOutput);
            }
        }
Example #4
0
        public void TransformCallsLessCompiler()
        {
            var asset = new Mock <IAsset>();

            asset.SetupGet(a => a.SourceFile.FullPath).Returns("test.less");

            var sourceInput    = "source-input";
            var compilerOutput = "compiler-output";
            var compiler       = StubCompiler(sourceInput, compilerOutput);

            var transformer = new CompileAsset(compiler);

            var getResultStream = transformer.Transform(
                () => sourceInput.AsStream(),
                asset.Object
                );

            using (var reader = new StreamReader(getResultStream()))
            {
                reader.ReadToEnd().ShouldEqual(compilerOutput);
            }
        }
 void ApplyTransform(CompileAsset transformer)
 {
     transformer.Transform(() => Stream.Null, asset.Object)().Dispose();
 }