Exemplo n.º 1
0
 public BundleCollection(CassetteSettings settings, IFileSearchProvider fileSearchProvider, IBundleFactoryProvider bundleFactoryProvider, IBundleCollectionInitializer bundleCollectionInitializer)
 {
     this.settings                    = settings;
     this.fileSearchProvider          = fileSearchProvider;
     this.bundleFactoryProvider       = bundleFactoryProvider;
     this.bundleCollectionInitializer = bundleCollectionInitializer;
 }
        protected BundleCollectionTestsBase()
        {
            tempDirectory = new TempDirectory();
            factory       = new Mock <IBundleFactory <TestableBundle> >();
            factory
            .Setup(f => f.CreateBundle(It.IsAny <string>(), It.IsAny <IEnumerable <IFile> >(), It.IsAny <BundleDescriptor>()))
            .Callback <string, IEnumerable <IFile>, BundleDescriptor>((path, files, descriptor) => FilesUsedToCreateBundle = files.Select(f => f.FullPath).ToArray())
            .Returns <string, IEnumerable <IFile>, BundleDescriptor>(
                (path, files, d) => new TestableBundle(path)
                );

            fileSearch = new Mock <IFileSearch>();
            fileSearch
            .Setup(s => s.FindFiles(It.IsAny <IDirectory>()))
            .Returns <IDirectory>(d => d.GetFiles("*.*", SearchOption.AllDirectories));

            settings = new CassetteSettings
            {
                SourceDirectory = new FileSystemDirectory(tempDirectory),
            };

            bundleFactoryProvider = new Mock <IBundleFactoryProvider>();
            bundleFactoryProvider
            .Setup(p => p.GetBundleFactory <TestableBundle>())
            .Returns(factory.Object);

            var fileSearchProvider = new Mock <IFileSearchProvider>();

            fileSearchProvider
            .Setup(p => p.GetFileSearch(It.IsAny <Type>()))
            .Returns(fileSearch.Object);

            bundles = new BundleCollection(settings, fileSearchProvider.Object, bundleFactoryProvider.Object);
        }
        public FileSystemWatchingBundleRebuilder_Tests()
        {
            tempDirectory = new TempDirectory();
            Directory.CreateDirectory(Path.Combine(tempDirectory, "cache"));
            var settings = new CassetteSettings
            {
                SourceDirectory = new FileSystemDirectory(tempDirectory),
                CacheDirectory = new FileSystemDirectory(Path.Combine(tempDirectory, "cache")),
                IsFileSystemWatchingEnabled = true
            };
            bundles = new BundleCollection(settings, Mock.Of<IFileSearchProvider>(), Mock.Of<IBundleFactoryProvider>());
            bundleConfiguration = new Mock<IConfiguration<BundleCollection>>();

            var bundle = new TestableBundle("~");
            var asset1 = new StubAsset("~/test.js");
            var asset2 = new StubAsset("~/sub/test2.js");
            asset1.AddRawFileReference("~/image.png");
            bundle.Assets.Add(asset1);
            bundle.Assets.Add(asset2);
            bundles.Add(bundle);

            fileSearch = new Mock<IFileSearch>();
            fileSearch
                .Setup(s => s.IsMatch(It.IsAny<string>()))
                .Returns<string>(path => path.EndsWith(".js"));

            var initializer = new BundleCollectionInitializer(new[] { bundleConfiguration.Object }, new ExternalBundleGenerator(Mock.Of<IBundleFactoryProvider>(), settings));
            rebuilder = new FileSystemWatchingBundleRebuilder(settings, bundles, initializer, new[] { fileSearch.Object });
        }
        public FileSystemWatchingBundleRebuilder_Tests()
        {
            tempDirectory = new TempDirectory();
            Directory.CreateDirectory(Path.Combine(tempDirectory, "cache"));
            var settings = new CassetteSettings
            {
                SourceDirectory             = new FileSystemDirectory(tempDirectory),
                CacheDirectory              = new FileSystemDirectory(Path.Combine(tempDirectory, "cache")),
                IsFileSystemWatchingEnabled = true
            };

            bundles             = new BundleCollection(settings, Mock.Of <IFileSearchProvider>(), Mock.Of <IBundleFactoryProvider>(), Mock.Of <IBundleCollectionInitializer>());
            bundleConfiguration = new Mock <IConfiguration <BundleCollection> >();

            var bundle = new TestableBundle("~");
            var asset1 = new StubAsset("~/test.js");
            var asset2 = new StubAsset("~/sub/test2.js");

            asset1.AddRawFileReference("~/image.png");
            bundle.Assets.Add(asset1);
            bundle.Assets.Add(asset2);
            bundles.Add(bundle);

            fileSearch = new Mock <IFileSearch>();
            fileSearch
            .Setup(s => s.IsMatch(It.IsAny <string>()))
            .Returns <string>(path => path.EndsWith(".js"));

            var initializer = new BundleCollectionInitializer(new[] { bundleConfiguration.Object }, new ExternalBundleGenerator(Mock.Of <IBundleFactoryProvider>(), settings));

            rebuilder = new FileSystemWatchingBundleRebuilder(settings, bundles, initializer, new[] { fileSearch.Object });
        }
Exemplo n.º 5
0
 protected override Bundle CreateBundleCore(CassetteSettings settings)
 {
     return(new TestableBundle(Path)
     {
         Hash = Hash
     });
 }
Exemplo n.º 6
0
 protected ReferenceBuilder_Reference_TestBase()
 {
     settings = new CassetteSettings();
     bundles  = new BundleCollection(settings, Mock.Of <IFileSearchProvider>(), Mock.Of <IBundleFactoryProvider>(), Mock.Of <IBundleCollectionInitializer>());
     bundleFactoryProvider = new Mock <IBundleFactoryProvider>();
     placeholderTracker    = new Mock <IPlaceholderTracker>();
     builder = new ReferenceBuilder(bundles, placeholderTracker.Object, bundleFactoryProvider.Object, settings);
 }
Exemplo n.º 7
0
 public CacheAwareBundleCollectionInitializer(IEnumerable <IConfiguration <BundleCollection> > bundleConfigurations, IBundleCollectionCache cache, ExternalBundleGenerator externalBundleGenerator, ManifestValidator manifestValidator, CassetteSettings settings)
 {
     this.bundleConfigurations = bundleConfigurations;
     this.cache = cache;
     this.externalBundleGenerator = externalBundleGenerator;
     this.manifestValidator       = manifestValidator;
     this.settings = settings;
 }
 public CacheAwareBundleCollectionInitializer(IEnumerable<IConfiguration<BundleCollection>> bundleConfigurations, IBundleCollectionCache cache, ExternalBundleGenerator externalBundleGenerator, ManifestValidator manifestValidator, CassetteSettings settings)
 {
     this.bundleConfigurations = bundleConfigurations;
     this.cache = cache;
     this.externalBundleGenerator = externalBundleGenerator;
     this.manifestValidator = manifestValidator;
     this.settings = settings;
 }
Exemplo n.º 9
0
 internal void Process(CassetteSettings settings)
 {
     if (IsProcessed)
     {
         throw new InvalidOperationException("Bundle has already been processed.");
     }
     ProcessCore(settings);
     IsProcessed = true;
 }
Exemplo n.º 10
0
        public void ConstructorAppliesConfigurationsInOrderDefinedbyAttribute()
        {
            var configA  = new ConfigA();
            var configB  = new ConfigB();
            var settings = new CassetteSettings(new IConfiguration <CassetteSettings>[] { configB, configA });

            // Each config appends a letter to Version so we can test the order that they were called.
            settings.Version.ShouldEqual("AB");
        }
Exemplo n.º 11
0
        public void ConstructorAppliesConfigurations()
        {
            var configA = new ConfigA();
            var configB = new ConfigB();

            var settings = new CassetteSettings(new IConfiguration <CassetteSettings>[] { configA, configB });

            configA.AssertWasCalled(settings);
            configB.AssertWasCalled(settings);
        }
        Mock <ICassetteApplication> CreateApplication()
        {
            var app      = new Mock <ICassetteApplication>();
            var settings = new CassetteSettings {
                SourceDirectory = Mock.Of <IDirectory>()
            };

            app.SetupGet(a => a.Settings).Returns(settings);
            return(app);
        }
        public FileSystemWatchingBundleRebuilder(CassetteSettings settings, BundleCollection bundles, IBundleCollectionInitializer initializer, IEnumerable <IFileSearch> fileSearches)
        {
            this.settings     = settings;
            this.bundles      = bundles;
            this.initializer  = initializer;
            this.fileSearches = fileSearches;

            bundleDescriptorFilenames = GetBundleDescriptorFilenames();

            // Initially use the bundles collection, but this will get updated in the Changed event handler.
            readOnlyBundles  = new ReadOnlyCollection <Bundle>(bundles.ToList());
            bundles.Changed += HandleBundlesChanged;
        }
        public FileSystemWatchingBundleRebuilder(CassetteSettings settings, BundleCollection bundles, IBundleCollectionInitializer initializer, IEnumerable<IFileSearch> fileSearches)
        {
            this.settings = settings;
            this.bundles = bundles;
            this.initializer = initializer;
            this.fileSearches = fileSearches;

            bundleDescriptorFilenames = GetBundleDescriptorFilenames();

            // Initially use the bundles collection, but this will get updated in the Changed event handler.
            readOnlyBundles = new ReadOnlyCollection<Bundle>(bundles.ToList());
            bundles.Changed += HandleBundlesChanged;
        }
Exemplo n.º 15
0
        T CreateApplication()
        {
            lock (creationLock)
            {
                var cacheVersion           = GetConfigurationVersion();
                var settings               = new CassetteSettings(cacheVersion);
                var bundleContainerFactory = settings.GetBundleContainerFactory(CassetteConfigurations);
                var bundleContainer        = bundleContainerFactory.CreateBundleContainer();

                Trace.Source.TraceInformation("IsDebuggingEnabled: {0}", settings.IsDebuggingEnabled);
                Trace.Source.TraceInformation("Cache version: {0}", cacheVersion);
                Trace.Source.TraceInformation("Creating Cassette application object");

                return(CreateCassetteApplicationCore(bundleContainer, settings));
            }
        }
Exemplo n.º 16
0
        static IBundleContainer CreateBundleContainer(IEnumerable <Bundle> bundles, CassetteSettings settings, string cacheVersion)
        {
            IBundleContainerFactory containerFactory;

            if (settings.IsDebuggingEnabled)
            {
                containerFactory = new BundleContainerFactory(settings.BundleFactories);
            }
            else
            {
                containerFactory = new CachedBundleContainerFactory(
                    new BundleCache(
                        cacheVersion,
                        settings
                        ),
                    settings.BundleFactories
                    );
            }
            return(containerFactory.Create(bundles, settings));
        }
Exemplo n.º 17
0
 protected CassetteApplicationBase(IBundleContainer bundleContainer, CassetteSettings settings)
 {
     this.settings        = settings;
     this.bundleContainer = bundleContainer;
 }
Exemplo n.º 18
0
 public ReferenceBuilder(IBundleContainer bundleContainer, IDictionary <Type, IBundleFactory <Bundle> > bundleFactories, IPlaceholderTracker placeholderTracker, CassetteSettings settings)
 {
     this.bundleContainer    = bundleContainer;
     this.bundleFactories    = bundleFactories;
     this.placeholderTracker = placeholderTracker;
     this.settings           = settings;
 }
Exemplo n.º 19
0
 protected abstract void ProcessCore(CassetteSettings settings);
Exemplo n.º 20
0
 public FileContentHasher(CassetteSettings settings)
 {
     this.settings = settings;
 }
Exemplo n.º 21
0
 public FileContentHasher(CassetteSettings settings)
 {
     this.settings = settings;
 }
Exemplo n.º 22
0
 protected abstract void ProcessCore(CassetteSettings settings);
Exemplo n.º 23
0
 internal abstract void Process(CassetteSettings settings);
Exemplo n.º 24
0
 protected CassetteApplicationBase(IEnumerable <Bundle> bundles, CassetteSettings settings)
 {
     this.settings   = settings;
     bundleContainer = CreateBundleContainer(bundles);
 }
Exemplo n.º 25
0
 public PageHelper(BundleCollection bundles, IUrlGenerator urlGenerator, CassetteSettings settings)
 {
     this.bundles = bundles;
     this.urlGenerator = urlGenerator;
     this.settings = settings;
 }
Exemplo n.º 26
0
 internal override void Process(CassetteSettings settings)
 {
     WasProcessed = true;
 }
Exemplo n.º 27
0
 protected abstract T CreateCassetteApplicationCore(IBundleContainer bundleContainer, CassetteSettings settings);
Exemplo n.º 28
0
 public override void Configure(CassetteSettings settings)
 {
     base.Configure(settings);
     settings.Version += "B";
 }
 public ExternalBundleGenerator(IBundleFactoryProvider bundleFactoryProvider, CassetteSettings settings)
 {
     this.bundleFactoryProvider = bundleFactoryProvider;
     this.settings = settings;
 }
Exemplo n.º 30
0
 protected override void ProcessCore(CassetteSettings settings)
 {
     WasProcessed = true;
 }
Exemplo n.º 31
0
 public ReferenceBuilder(BundleCollection allBundles, IPlaceholderTracker placeholderTracker, IBundleFactoryProvider bundleFactoryProvider, CassetteSettings settings)
 {
     this.allBundles            = allBundles;
     this.placeholderTracker    = placeholderTracker;
     this.bundleFactoryProvider = bundleFactoryProvider;
     this.settings = settings;
 }
Exemplo n.º 32
0
 internal void Process(CassetteSettings settings)
 {
     if (IsProcessed)
     {
         throw new InvalidOperationException("Bundle has already been processed.");
     }
     ProcessCore(settings);
     IsProcessed = true;
 }
Exemplo n.º 33
0
 protected CassetteApplicationBase(IEnumerable <Bundle> bundles, CassetteSettings settings, string cacheVersion)
 {
     this.settings   = settings;
     bundleContainer = CreateBundleContainer(bundles, settings, cacheVersion);
 }
 public ExternalBundleGenerator(IBundleFactoryProvider bundleFactoryProvider, CassetteSettings settings)
 {
     this.bundleFactoryProvider = bundleFactoryProvider;
     this.settings = settings;
 }