コード例 #1
0
 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));
     _context      = MockRepository.GenerateMock <HttpContextBase>();
     _routeId      = Guid.NewGuid();
     _watcherRoute = new CssBundleWatcherRoute("route", _routeId, "relative", _watcher, _httpRuntime, _systemClock);
     _response     = _watcherRoute.ProcessResponseAsync(_context).Result;
 }
コード例 #2
0
			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);
			}
コード例 #3
0
        public AutoRouteCollection CssBundle(Bundle bundle, string routeName, Scheme scheme, string relativePath, IAssetConcatenator concatenator, IEnumerable <IAssetTransformer> transformers)
        {
            ThrowIfNoContainer();

            bundle.ThrowIfNull("bundle");
            routeName.ThrowIfNull("routeName");
            relativePath.ThrowIfNull("relativePath");
            concatenator.ThrowIfNull("concatenator");
            transformers.ThrowIfNull("transformers");

            var watcher     = new BundleWatcher(bundle, _container.GetInstance <IFileSystem>(), concatenator, transformers);
            var guidFactory = _container.GetInstance <IGuidFactory>();
            var httpRuntime = _container.GetInstance <IHttpRuntime>();
            var systemClock = _container.GetInstance <ISystemClock>();
            var route       = new CssBundleWatcherRoute(routeName, guidFactory.Random(), scheme, relativePath, watcher, httpRuntime, systemClock);

            return(AdditionalRoutes(route));
        }
コード例 #4
0
        public AutoRouteCollection CssBundle(Bundle bundle, string routeName, string relativePath, IComparer <AssetFile> assetOrder, IAssetConcatenator concatenator, IEnumerable <IAssetTransformer> transformers)
        {
            ThrowIfNoBundleDependencyContainer();

            bundle.ThrowIfNull("bundle");
            routeName.ThrowIfNull("routeName");
            relativePath.ThrowIfNull("relativePath");
            assetOrder.ThrowIfNull("assetOrder");
            concatenator.ThrowIfNull("concatenator");
            transformers.ThrowIfNull("transformers");

            var watcher = new BundleWatcher(bundle, _bundleDependencyContainer.GetInstance <IFileSystem>(), assetOrder, concatenator, transformers);
            var route   = new CssBundleWatcherRoute(
                routeName,
                _bundleDependencyContainer.GetInstance <IGuidFactory>(),
                relativePath,
                watcher,
                _bundleDependencyContainer.GetInstance <IHttpRuntime>(),
                _bundleDependencyContainer.GetInstance <ISystemClock>());

            return(AdditionalRoutes(route));
        }