public void SetUp()
 {
     _path = Path.GetTempFileName();
     File.WriteAllText(_path, ".css { text-align: right; }");
     _bundle = new Bundle().File("file1");
     _fileSystem = MockRepository.GenerateMock<IFileSystem>();
     _fileSystem.Stub(arg => arg.AbsolutePath("file1")).Return(_path);
     _fileSystem
         .Stub(arg => arg.OpenFile(_path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
         .WhenCalled(arg => arg.ReturnValue = File.OpenRead(_path))
         .Return(null);
     _concatenator = MockRepository.GenerateMock<IAssetConcatenator>();
     _concatenator
         .Stub(arg => arg.Concatenate(Arg<IEnumerable<string>>.Is.Anything))
         .WhenCalled(arg => arg.ReturnValue = ((IEnumerable<string>)arg.Arguments.First()).First())
         .Return(null);
     _transformer = MockRepository.GenerateMock<IAssetTransformer>();
     _transformer
         .Stub(arg => arg.Transform(Arg<string>.Is.Anything))
         .WhenCalled(arg => arg.ReturnValue = arg.Arguments.First())
         .Return(null);
     _watcher = new BundleWatcher(_bundle, _fileSystem, _concatenator, _transformer);
     _httpRuntime = MockRepository.GenerateMock<IHttpRuntime>();
     _systemClock = MockRepository.GenerateMock<ISystemClock>();
     _systemClock.Stub(arg => arg.UtcDateTime).Return(new DateTime(2012, 1, 1, 0, 0, 0, DateTimeKind.Utc));
     _routeId = Guid.NewGuid();
     _cssBundleWatcherRoute = new CssBundleWatcherRoute("route", _routeId, "relative", _watcher, _httpRuntime, _systemClock);
 }
Esempio n. 2
0
        public static Bundle FromFiles(IEnumerable<string> relativePaths)
        {
            relativePaths.ThrowIfNull("relativePaths");

            var bundle = new Bundle();

            return bundle.Files(relativePaths);
        }
Esempio n. 3
0
		public BundleRoute(Bundle bundle, string routeName, string relativePath, IAssetConcatenator concatenator, IEnumerable<IAssetTransformer> transformers)
		{
			bundle.ThrowIfNull("bundle");
			routeName.ThrowIfNull("routeName");
			relativePath.ThrowIfNull("relativePath");
			concatenator.ThrowIfNull("concatenator");
			transformers.ThrowIfNull("transformers");

			_bundle = bundle;
			_routeName = routeName;
			_relativePath = relativePath;
			_concatenator = concatenator;
			_transformers = transformers;
		}
Esempio n. 4
0
        public BundleWatcher(Bundle bundle, IFileSystem fileSystem, IComparer<AssetFile> assetOrder, IEnumerable<IAssetTransformer> transformers)
        {
            bundle.ThrowIfNull("bundle");
            fileSystem.ThrowIfNull("fileSystem");
            assetOrder.ThrowIfNull("assetOrder");
            transformers.ThrowIfNull("transformers");

            _bundle = bundle;
            _assetOrder = assetOrder;
            _transformers = transformers.ToArray();
            _fileSystem = fileSystem;
            _watchTimer.Elapsed += WatchTimerElapsed;
            RefreshContents();
            WatchForChanges();
        }
Esempio n. 5
0
        public BundleWatcher(Bundle bundle, IFileSystem fileSystem, IAssetConcatenator concatenator, IEnumerable<IAssetTransformer> transformers)
        {
            bundle.ThrowIfNull("bundle");
            fileSystem.ThrowIfNull("fileSystem");
            concatenator.ThrowIfNull("concatenator");
            transformers.ThrowIfNull("transformers");

            _bundle = bundle;
            _concatenator = concatenator;
            _transformers = transformers.ToArray();
            _fileSystem = fileSystem;
            _watchTimer.Elapsed += WatchTimerElapsed;
            RefreshContents();
            WatchForChanges();
        }
Esempio n. 6
0
 public void SetUp()
 {
     _path = Path.GetTempFileName();
     File.WriteAllText(_path, "contents");
     _bundle = new Bundle().File("file1");
     _fileSystem = MockRepository.GenerateMock<IFileSystem>();
     _fileSystem.Stub(arg => arg.AbsolutePath("file1")).Return(_path);
     _fileSystem
         .Stub(arg => arg.OpenFile(_path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
         .WhenCalled(arg => arg.ReturnValue = File.OpenRead(_path))
         .Return(null);
     _concatenator = MockRepository.GenerateMock<IAssetConcatenator>();
     _concatenator
         .Stub(arg => arg.Concatenate(Arg<IEnumerable<string>>.Is.Anything))
         .WhenCalled(arg => arg.ReturnValue = ((IEnumerable<string>)arg.Arguments.First()).First())
         .Return(null);
     _transformer = MockRepository.GenerateMock<IAssetTransformer>();
     _transformer
         .Stub(arg => arg.Transform(Arg<string>.Is.Anything))
         .WhenCalled(arg => arg.ReturnValue = arg.Arguments.First())
         .Return(null);
     _watcher = new BundleWatcher(_bundle, _fileSystem, _concatenator, _transformer);
 }
Esempio n. 7
0
			public void SetUp()
			{
				_bundle = new Bundle()
					.Directory("directory1")
					.File("file1");
				_fileSystem = MockRepository.GenerateMock<IFileSystem>();
				_fileSystem.Stub(arg => arg.AbsolutePath("directory1")).Return("directory1");
				_fileSystem.Stub(arg => arg.AbsolutePath("file1")).Return("file1");
				_fileSystem.Stub(arg => arg.AbsolutePath("file2")).Return("file2");
				_fileSystem.Stub(arg => arg.AbsolutePath("file3")).Return("file3");
				_fileSystem.Stub(arg => arg.GetDirectoryFiles("directory1", "*.*", SearchOption.AllDirectories)).Return(new[] { "file2", "file3" });
				_fileSystem
					.Stub(arg => arg.OpenFile(Arg<string>.Is.Anything, Arg<FileMode>.Is.Equal(FileMode.Open), Arg<FileAccess>.Is.Equal(FileAccess.Read), Arg<FileShare>.Is.Equal(FileShare.ReadWrite)))
					.WhenCalled(arg => arg.ReturnValue = new MemoryStream(Encoding.ASCII.GetBytes("ABC")))
					.Return(null);
				_comparer = MockRepository.GenerateMock<IComparer<AssetFile>>();
				_concatenator = MockRepository.GenerateMock<IAssetConcatenator>();
				_concatenator.Stub(arg => arg.Concatenate(Arg<IEnumerable<string>>.Is.Anything)).Return("");
				_transformer1 = MockRepository.GenerateMock<IAssetTransformer>();
				_transformer1.Stub(arg => arg.Transform(Arg<string>.Is.Anything)).Return("");
				_transformer2 = MockRepository.GenerateMock<IAssetTransformer>();
				_transformer2.Stub(arg => arg.Transform(Arg<string>.Is.Anything)).Return("");
				_bundle.GetContents(_fileSystem, _comparer, _concatenator, _transformer1, _transformer2);
			}
Esempio n. 8
0
 public BundleWatcher(Bundle bundle, IFileSystem fileSystem, IComparer<AssetFile> assetOrder, params IAssetTransformer[] transformers)
     : this(bundle, fileSystem, assetOrder, (IEnumerable<IAssetTransformer>)transformers)
 {
 }
Esempio n. 9
0
 public BundleWatcher(Bundle bundle, IFileSystem fileSystem, IAssetConcatenator concatenator, params IAssetTransformer[] transformers)
     : this(bundle, fileSystem, concatenator, (IEnumerable<IAssetTransformer>)transformers)
 {
 }
Esempio n. 10
0
			public void SetUp()
			{
				_bundle = new Bundle()
					.File("file1", Encoding.UTF8)
					.File("file2");
			}
Esempio n. 11
0
			public void SetUp()
			{
				_bundle = new Bundle()
					.Directory("directory1", Encoding.UTF8)
					.Directory("directory2");
			}
Esempio n. 12
0
		public BundleRoute(Bundle bundle, string routeName, string relativePath, IAssetConcatenator concatenator, params IAssetTransformer[] transformers)
			: this(bundle, routeName, relativePath, concatenator, (IEnumerable<IAssetTransformer>)transformers)
		{
		}