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);
 }
示例#2
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("");
     _transformer = MockRepository.GenerateMock<IAssetTransformer>();
     _transformer.Stub(arg => arg.Transform(Arg<string>.Is.Anything)).Return("");
     _bundle.GetContents(_fileSystem, _comparer, _concatenator, _transformer);
 }
示例#3
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);
 }