void AddCodeCoverageFile(string fileName, string coverageXml) { var stringReader = new StringReader(coverageXml); fakeFileSystem.Stub(fs => fs.FileExists(fileName)).Return(true); fakeFileSystem.Stub(fs => fs.CreateTextReader(fileName)).Return(stringReader); }
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); }
public void find_binary_directory_if_the_target_directory_does_not_exist() { theFileSystem .Stub(x => x.DirectoryExists(theFolder, "bin", CompileTargetEnum.debug.ToString())) .Return(false); theFileSystem.FindBinaryDirectory(theFolder, CompileTargetEnum.debug) .ShouldEqual(FileSystem.Combine(theFolder, "bin")); }
public void should_replace_keywords_in_file_content() { fileSystem.Stub(x => x.ReadTextFile(Arg <string> .Is.Anything, Arg <Action <string> > .Is.Anything)); keywordReplacer.Stub(x => x.Replace(Arg <string> .Is.Anything)).Return("some replaced text"); ClassUnderTest.KeywordReplacer = keywordReplacer; ClassUnderTest.ParseFile("somefile"); fileSystem.AssertWasCalled(x => x.WriteStringToFile(Arg <string> .Is.Anything, Arg <string> .Is.Equal("some replaced text"))); }
public void Add_hint_directory_throws_if_directory_does_not_exist() { const string hintDirectory = "hintDirectory"; fileSystem.Stub(fs => fs.DirectoryExists(hintDirectory)).Return(false); var exception = Assert.Throws <Exception>(() => controller.AddHintDirectory(hintDirectory)); Assert.AreEqual(Resources.Controller_Invalid_hint_directory_path_, exception.Message); }
public void User_options_are_not_loaded_if_the_file_does_not_exist() { const string projectLocation = "test.gallio"; fileSystem.Stub(fs => fs.FileExists(projectLocation + UserOptions.Extension)) .Return(false); controller.Handle(new ProjectLoaded(projectLocation)); xmlSerializer.AssertWasNotCalled(xs => xs.LoadFromXml <UserOptions>(Arg <string> .Is.Anything)); }
public void Setup() { _mockMp3Representation = MockRepository.GenerateStub<IMp3Representation>(); _mockMp3Representation.AlbumName = SomeAlbumName; _mockMp3Representation.ArtistName = SomeArtistName; _mockMp3Representation.FileName = SomeFileName; _mockFileSystem = MockRepository.GenerateStub<IFileSystem>(); _mockFileSystem.Stub(system => system.GetAllMp3Files(SomeStartDirectory)).Return(new List<string> { SomeFileName }); _mockMp3TagHierarchy = MockRepository.GenerateStub<IMp3TagsHierarchy>(); _mockMp3TagHierarchy.Stub(hierarchy => hierarchy.Artists).Return(new List<string> {SomeArtistName}); _mockMp3TagHierarchy.Stub(tagsHierarchy => tagsHierarchy.GetAlbumsForArtist(SomeArtistName)).Return( new List<string> {SomeAlbumName}); _mockMp3TagHierarchy.Stub( mp3TagsHierarchy => mp3TagsHierarchy.GetSongsForAlbumOfArtist(SomeAlbumName, SomeArtistName)).Return( new List<string> {SomeFileName}); _mockMp3FileReader = MockRepository.GenerateStub<IMp3FileReader>(); _mockMp3FileReader.Stub(reader => reader.RetrieveTagsFromMp3Files(new List<string> {SomeFileName})).Return( new List<IMp3Representation> { new Mp3Representation {AlbumName = SomeAlbumName, ArtistName = SomeArtistName, FileName = SomeFileName} }); _mp3LibrarySorter = new Mp3LibrarySorter.Mp3LibrarySorter(_mockFileSystem, SomeStartDirectory, _mockMp3TagHierarchy, _mockMp3FileReader); _mp3LibrarySorter.CreateFoldersForArtists(); }
void AddTextTemplatesToFolder(string path, params string[] fileNames) { DirectoryName templateFolder = DirectoryName.Create(path); var templateFileNames = fileNames.Select(FileName.Create).ToArray(); fakeFileSystem.Stub(f => f.GetFiles(templateFolder, "*.tt")).Return(templateFileNames); }
public void SetUp() { _directoryAsset = new DirectoryAsset("directory", Encoding.UTF8, "*.txt", SearchOption.TopDirectoryOnly); _fileSystem = MockRepository.GenerateMock<IFileSystem>(); _tempPath = Path.GetTempPath(); _fileSystem.Stub(arg => arg.AbsolutePath("directory")).Return(_tempPath); _watcher = _directoryAsset.GetFileSystemWatcher(_fileSystem); }
public void SetUp() { _fileAsset = new FileAsset("file", Encoding.UTF8); _fileSystem = MockRepository.GenerateMock<IFileSystem>(); _tempPath = Path.GetTempFileName(); _fileSystem.Stub(arg => arg.AbsolutePath("file")).Return(_tempPath); _watcher = _fileAsset.GetFileSystemWatcher(_fileSystem); }
public void AddFiles_Test() { TestProject testProject = new TestProject(); projectTreeModel.TestProject = testProject; string fileName = Assembly.GetExecutingAssembly().Location; List <string> list = new List <string>(new[] { fileName }); fileSystem.Stub(fs => fs.FileExists(fileName)).Return(true); var progressMonitor = MockProgressMonitor.Instance; Assert.Count(0, projectController.TestPackage.Files); projectController.AddFiles(progressMonitor, list); Assert.Count(1, projectController.TestPackage.Files); Assert.AreEqual(fileName, projectController.TestPackage.Files[0].ToString()); }
public void SetUp() { fileSystem = MockRepository.GenerateMock <IFileSystem>(); theRegistry = new AliasRegistry(); fileSystem.Stub(x => x.LoadFromFile <AliasRegistry>(AliasRegistry.ALIAS_FILE)) .Return(theRegistry); theCommand = new AliasCommand(); }
public void Load_files_from_arguments_should_be_added_if_they_exist() { const string file1 = "test1.dll"; const string file2 = "test2.dll"; var files = new List <string>() { file1 }; var arguments = new IcarusArguments { Files = new[] { file1, file2 } }; fileSystem.Stub(fs => fs.FileExists(file1)).Return(true); commandFactory.Stub(cf => cf.CreateAddFilesCommand(files)).Return(command); applicationController.Arguments = arguments; applicationController.Load(); taskManager.AssertWasCalled(t => t.QueueTask(command)); }
public void SetUp() { _documentService = MockRepository.GenerateStub<IDocumentService>(); _fileSystem = MockRepository.GenerateStub<IFileSystem>(); const string str = "Documento Bolletta di Prova"; _documentoSpesa = new byte[str.Length * sizeof(char)]; Buffer.BlockCopy(str.ToCharArray(), 0, _documentoSpesa, 0, _documentoSpesa.Length); _fileSystem = MockRepository.GenerateStub<IFileSystem>(); _fileSystem.Stub(x => x.ReadAllBytes(Arg<string>.Is.Anything)).Return(_documentoSpesa); IList<Spesa> listaSpese = new List<Spesa>(); _utente = new Utente("PP"); _logTransazione = new LogTransazione(AzioneUtente.TransazioneContabile, _utente, Guid.NewGuid().ToString()); _azienda = new Azienda("PROV", "Prova") { ID = 1 }; _condominio1 = new Condominio("Condominio 1", 31, 12, 2014, _azienda) { CodiceFiscale = "91138030373" }; _annoGestionaleCondominio1 = new AnnoGestionale(_condominio1, 2014, 2014); _esercizioCondominio1 = new Esercizio(_condominio1, new DateTime(2014, 1, 1), new DateTime(2014, 12, 31), _annoGestionaleCondominio1, GestioneEsercizioEnum.Ordinario); _condominio2 = new Condominio("Condominio 2", 31, 12, 2014, _azienda) { CodiceFiscale = "90036640374" }; _annoGestionaleCondominio2 = new AnnoGestionale(_condominio2, 2014, 2014); _esercizioCondominio2 = new Esercizio(_condominio2, new DateTime(2014, 1, 1), new DateTime(2014, 12, 31), _annoGestionaleCondominio2, GestioneEsercizioEnum.Ordinario); _persona = new Persona(TipoPersonaEnum.Fisica, "Mario", "Rossi", _azienda.ID, true); _fornitore = new Fornitore(_persona, _azienda.ID); _documentiBolletteDTO = buildDocumentoBolletteDTO(); foreach (var documentoBollettaDTO in _documentiBolletteDTO) { var esercizio = _esercizioCondominio1; if (documentoBollettaDTO.CodiceFiscaleCliente == _condominio2.CodiceFiscale) esercizio = _esercizioCondominio2; listaSpese.Add(new Spesa(_fornitore, esercizio, _logTransazione) { ID = documentoBollettaDTO.IdSpesa, NumeroDocumento = documentoBollettaDTO.NumeroDocumento, DataDocumento = documentoBollettaDTO.DataDocumento }); } _daoFactory = MockRepository.GenerateStub<IDaoFactory>(); _daoFactory.Stub(x => x.GetCondominioDao().GetByCodiceFiscale(_condominio1.CodiceFiscale)).Return(_condominio1); _daoFactory.Stub(x => x.GetCondominioDao().GetByCodiceFiscale(_condominio2.CodiceFiscale)).Return(_condominio2); _spesaDao = MockRepository.GenerateStub<ISpesaDao>(); _documentoDao = MockRepository.GenerateStub<IDocumentoDao>(); _daoFactory.Stub(x => x.GetSpesaDao()).Return(_spesaDao); _daoFactory.Stub(x => x.GetDocumentoDao()).Return(_documentoDao); foreach (var spesa in listaSpese) _spesaDao.Stub(x => x.Find(spesa.ID, false)).Return(spesa); _utenzaDocumentoService = MockRepository.GenerateMock<UtenzaDocumentoService>(_daoFactory, _documentService, _fileSystem); }
public void SetUp() { theFileSystem = MockRepository.GenerateStub <IFileSystem>(); theFile = TestFileHelper.RelativePath("serenity.txt"); theFileContents = "include:MyProject.Web"; theFileSystem.Stub(x => x.ReadStringFromFile(theFile.ToFullPath())).Return(theFileContents); theLoader = new JasmineConfigLoader(theFileSystem); theConfiguration = theLoader.LoadFrom(theFile); }
private void SetExpectationsForDirsWithoutFiles(IFileSystem fileSystem) { HashSet <string> dirsWithoutFiles = new HashSet <string> (filesByDirs.Keys); dirsWithoutFiles.ExceptWith(dirsByDirs.Keys); foreach (string dirWithoutFiles in dirsWithoutFiles) { string dir = dirWithoutFiles; fileSystem.Stub(x => x.GetDirectorySubdirectories(dir)).Return(new IDirectoryInformation[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); }
public void SetUp() { theFileSystem = MockRepository.GenerateStub <IFileSystem>(); theFile = TestFileHelper.RelativePath("serenity.txt"); theFileContents = new StringBuilder() .AppendLine("exclude:MyProject.Web{0}.idea".ToFormat(Path.DirectorySeparatorChar)) .AppendLine("exclude:MyProject.Web{0}Web.config".ToFormat(Path.DirectorySeparatorChar)) .ToString(); theFileSystem.Stub(x => x.ReadStringFromFile(theFile.ToFullPath())).Return(theFileContents); theLoader = new JasmineConfigLoader(theFileSystem); theConfiguration = theLoader.LoadFrom(theFile); }
private void thePackageManifestFileExists() { theFileSystem.Stub( x => x.FileExists(theInput.Directory, PackageManifest.FILE)) .Return(true); theFileSystem.Stub( x => x.LoadFromFile <PackageManifest>(theInput.Directory, PackageManifest.FILE)) .Return(thePackageManifest); }
private void SetSubdirectoriesExpectations(IFileSystem fileSystem) { foreach (KeyValuePair <string, List <string> > dirPair in dirsByDirs) { string dirPath = dirPair.Key; List <IDirectoryInformation> dirInfos = new List <IDirectoryInformation>(); foreach (string dirInDir in dirPair.Value) { IDirectoryInformation dirInfo = MockRepository.GenerateStub <IDirectoryInformation>(); dirInfo.Stub(x => x.FullName).Return(Path.Combine(dirPath, dirInDir)); dirInfos.Add(dirInfo); } fileSystem.Stub(x => x.GetDirectorySubdirectories(dirPath)).Return(dirInfos.ToArray()); } }
private void SetFilesExpectations(IFileSystem fileSystem) { foreach (KeyValuePair <string, List <string> > filesInDirPair in filesByDirs) { string dirPath = filesInDirPair.Key; List <IFileInformation> fileInfos = new List <IFileInformation>(); foreach (string fileInDir in filesInDirPair.Value) { IFileInformation fileInfo = MockRepository.GenerateStub <IFileInformation>(); fileInfo.Stub(x => x.FullName).Return(Path.Combine(dirPath, fileInDir)); fileInfos.Add(fileInfo); } fileSystem.Stub(x => x.GetDirectoryFiles(dirPath)).Return(fileInfos.ToArray()); } }
protected override void beforeEach() { const string projectName = "TestProject"; theInput = new NewCommandInput { ProjectName = projectName }; fileSystem = MockRepository.GenerateStub <IFileSystem>(); zipService = MockRepository.GenerateStub <IZipFileService>(); keywordReplacer = MockRepository.GenerateStub <IKeywordReplacer>(); processFactory = MockRepository.GenerateStub <IProcessFactory>(); fileSystem.Stub(x => x.FindFiles(Arg <string> .Is.Anything, Arg <FileSet> .Is.NotNull)).Return(new string[0]); ClassUnderTest.FileSystem = fileSystem; ClassUnderTest.ZipService = zipService; }
private void StubGeneratedPath(string path) { reportController.Stub(rc => rc.ConvertSavedReport(Arg <string> .Is.Anything, Arg <string> .Is.Anything, Arg <IProgressMonitor> .Is.Anything)).Return(path); fileSystem.Stub(fs => fs.FileExists(path)).Return(true); }
public void SetUp() { _fileFilter = MockRepository.GenerateMock<IFileFilter>(); _fileFilter.Stub(arg => arg.Filter("file1")).Return(FilterResult.Include); _fileFilter.Stub(arg => arg.Filter("file2")).Return(FilterResult.Exclude); _directoryAsset = new DirectoryAsset("directory", Encoding.UTF8, "*.txt", SearchOption.TopDirectoryOnly, _fileFilter); _fileSystem = MockRepository.GenerateMock<IFileSystem>(); _fileSystem.Stub(arg => arg.AbsolutePath("directory")).Return("directory"); _fileSystem.Stub(arg => arg.GetDirectoryFiles("directory", "*.txt", SearchOption.TopDirectoryOnly)).Return(new[] { "file1", "file2" }); _resolveAssetFiles = _directoryAsset.ResolveAssetFiles(_fileSystem).ToArray(); }
void SetTempFileNameCreated(string tempFileName) { fakeFileSystem.Stub(fs => fs.CreateTempFile(Arg <string> .Is.Anything)) .Return(tempFileName); }
private void SetUpOptionsController(Settings settings) { fileSystem.Stub(fs => fs.FileExists(Arg <string> .Is.Anything)).Return(true); xmlSerializer.Stub(xs => xs.LoadFromXml <Settings>(Arg <string> .Is.Anything)).Return(settings); optionsController.Load(); }
private void StubAvailablePlugins(params string[] plugins) { fileSystem .Stub(fs => fs.GetFilesInDirectory(Arg <string> .Is.Anything, Arg <string> .Is.Anything, Arg <SearchOption> .Is.Anything)) .Return(plugins); }
public void SetUp() { fileSystem = MockRepository.GenerateMock<IFileSystem>(); theRegistry = new AliasRegistry(); fileSystem.Stub(x => x.LoadFromFile<AliasRegistry>(AliasRegistry.ALIAS_FILE)) .Return(theRegistry); theCommand = new AliasCommand(); }
public void SetUp() { theFileSystem = MockRepository.GenerateStub<IFileSystem>(); theFile = TestFileHelper.RelativePath("serenity.txt"); theFileContents = "exclude:MyProject.Web{0}.idea".ToFormat(Path.DirectorySeparatorChar); theFileSystem.Stub(x => x.ReadStringFromFile(theFile.ToFullPath())).Return(theFileContents); theLoader = new JasmineConfigLoader(theFileSystem); theConfiguration = theLoader.LoadFrom(theFile); }
public void SetUp() { _fileAsset = new FileAsset("file", Encoding.UTF8); _fileSystem = MockRepository.GenerateMock<IFileSystem>(); _fileSystem.Stub(arg => arg.AbsolutePath("file")).Return("file"); _resolveAssetFiles = _fileAsset.ResolveAssetFiles(_fileSystem).ToArray(); }
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); }
private void StubAvailablePlugins(params int[] availableVersions) { fileSystem.Stub(fs => fs.GetFilesInDirectory(Arg <string> .Is.Anything, Arg <string> .Is.Anything, Arg <SearchOption> .Is.Anything)) .Return(Array.ConvertAll(availableVersions, version => GetPluginFileName(version))); }
public void SetUp() { theFileSystem = MockRepository.GenerateStub<IFileSystem>(); theFile = TestFileHelper.RelativePath("serenity.txt"); theFileContents = new StringBuilder() .AppendLine("include:MyProject.Web") .AppendLine("include:MyProject.Web2") .ToString(); theFileSystem.Stub(x => x.ReadStringFromFile(theFile.ToFullPath())).Return(theFileContents); theLoader = new JasmineConfigLoader(theFileSystem); theConfiguration = theLoader.LoadFrom(theFile); }