public void GivenFactoryThatUsesConfiguration_WhenCreateContainer_ThenResultingBundlesAreProcessed()
        {
            using (var path = new TempDirectory())
            {
                Directory.CreateDirectory(Path.Combine(path, "scripts"));

                var configuration = new StubConfiguration(bundles => bundles.Add<ScriptBundle>("scripts"));
                var factory = new CassetteApplicationContainerFactory(
                    new DelegateCassetteConfigurationFactory(() => new[] { configuration }),
                    new CassetteConfigurationSection(),
                    path,
                    "/",
                    false,
                    Mock.Of<HttpContextBase>
                );

                var container = factory.CreateContainer();
                var bundle = container.Application.FindBundleContainingPath<ScriptBundle>("~/scripts");
                bundle.IsProcessed.ShouldBeTrue();
            }
        }
        public void GivenStylesheetWithExternalReference_WhenCreateContainer_ThenExternalBundleAddedToBundleCollection()
        {
            using (var path = new TempDirectory())
            {
                Directory.CreateDirectory(Path.Combine(path, "styles"));
                File.WriteAllText(Path.Combine(path, "styles", "asset.css"), "/* @reference http://example.com */");

                var configuration = new StubConfiguration(bundles => bundles.Add<StylesheetBundle>("styles"));
                var factory = new CassetteApplicationContainerFactory(
                    new DelegateCassetteConfigurationFactory(() => new[] { configuration }),
                    new CassetteConfigurationSection(),
                    path,
                    "/",
                    false,
                    Mock.Of<HttpContextBase>
                );

                var container = factory.CreateContainer();

                container.Application.Bundles.Any(
                    b => b is ExternalStylesheetBundle && b.Path == "http://example.com"
                ).ShouldBeTrue();
            }
        }
    private CassetteApplication InitializeApplication()
    {
      if (currentContext.Value == null)
        throw new ApplicationException("currentContext.Value must be set before InitializeApplication is called");

      lock (initializeApplicationLock) {
        if (container != null)
          return container.Application;

        var applicationRoot = rootPathProvider.GetRootPath();
      
        var factory = new CassetteApplicationContainerFactory(
          new AssemblyScanningCassetteConfigurationFactory(AppDomain.CurrentDomain.GetAssemblies()),
          new CassetteConfigurationSection(),
          applicationRoot,
          "/",
          !ShouldOptimizeOutput,
          GetCurrentContext,
          routeGenerator);

        container = factory.CreateContainer();

        getApplication = GetApplication;
        return container.Application;
      }
    }