public void WithPreprocessor_Uses_Instance_Preprocessors()
        {
            var stylePreprocessor  = new StubStylePreprocessor();
            var globalPreprocessor = new StubGlobalPreprocessor();

            CSSBundle cssBundle = cssBundleFactory
                                  .WithHasher(hasher)
                                  .WithDebuggingEnabled(false)
                                  .WithContents("start")
                                  .Create();

            string tag = cssBundle
                         .Add("~/css/test.style.global")
                         .WithPreprocessor(stylePreprocessor)
                         .WithPreprocessor(globalPreprocessor)
                         .Render("~/css/output.css");

            string contents =
                cssBundleFactory.FileWriterFactory.Files[TestUtilities.PrepareRelativePath(@"css\output.css")];

            Assert.AreEqual("<link rel=\"stylesheet\" type=\"text/css\" href=\"css/output.css?r=hash\" />", tag);
            Assert.AreEqual("styley", contents);

            Assert.AreEqual("globey", stylePreprocessor.CalledWith);
            Assert.AreEqual("start", globalPreprocessor.CalledWith);

            Assert.IsEmpty(Configuration.Instance.Preprocessors.Where(x => !(x is NullPreprocessor)));
        }
        public void Css_Stops_At_First_Extension_With_No_Defined_Preprocessor()
        {
            var stylePreprocessor  = new StubStylePreprocessor();
            var globalPreprocessor = new StubGlobalPreprocessor();

            using (new StylePreprocessorScope <StubStylePreprocessor>(stylePreprocessor))
                using (new GlobalPreprocessorScope <StubGlobalPreprocessor>(globalPreprocessor))
                {
                    CSSBundle cssBundle = cssBundleFactory
                                          .WithHasher(hasher)
                                          .WithDebuggingEnabled(false)
                                          .WithContents("start")
                                          .Create();

                    string tag = cssBundle
                                 .Add("~/css/test.style.fake.global.bogus")
                                 .Render("~/css/output.css");

                    string contents =
                        cssBundleFactory.FileWriterFactory.Files[TestUtilities.PrepareRelativePath(@"css\output.css")];

                    Assert.AreEqual("<link rel=\"stylesheet\" type=\"text/css\" href=\"css/output.css?r=hash\" />", tag);
                    Assert.AreEqual("start", contents);

                    Assert.Null(stylePreprocessor.CalledWith);
                    Assert.Null(globalPreprocessor.CalledWith);
                }
        }
        public void Css_Global_Then_Style()
        {
            var stylePreprocessor  = new StubStylePreprocessor();
            var globalPreprocessor = new StubGlobalPreprocessor();

            using (new StylePreprocessorScope <StubStylePreprocessor>(stylePreprocessor))
                using (new GlobalPreprocessorScope <StubGlobalPreprocessor>(globalPreprocessor))
                {
                    CSSBundle cssBundle = cssBundleFactory
                                          .WithHasher(hasher)
                                          .WithDebuggingEnabled(false)
                                          .WithContents("start")
                                          .Create();

                    string tag = cssBundle
                                 .Add("~/css/test.style.global")
                                 .Render("~/css/output.css");

                    string contents =
                        cssBundleFactory.FileWriterFactory.Files[TestUtilities.PrepareRelativePath(@"css\output.css")];

                    Assert.AreEqual("<link rel=\"stylesheet\" type=\"text/css\" href=\"css/output.css?r=0B5C0EC6F2D8CEA452236626242443B7\" />", tag);
                    Assert.AreEqual("styley", contents);

                    Assert.AreEqual("globey", stylePreprocessor.CalledWith);
                    Assert.AreEqual("start", globalPreprocessor.CalledWith);
                }
        }