本文整理汇总了C#中IFileSystem.Stub方法的典型用法代码示例。如果您正苦于以下问题:C# IFileSystem.Stub方法的具体用法?C# IFileSystem.Stub怎么用?C# IFileSystem.Stub使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IFileSystem
的用法示例。
在下文中一共展示了IFileSystem.Stub方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SetUp
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: Setup
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();
}
示例3: SetUp
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);
}
示例4: SetUp
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);
}
示例5: SetUp
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);
}
示例6: SetUp
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);
}
示例7: SetUp
public void SetUp()
{
fileSystem = MockRepository.GenerateMock<IFileSystem>();
theRegistry = new AliasRegistry();
fileSystem.Stub(x => x.LoadFromFile<AliasRegistry>(AliasRegistry.ALIAS_FILE))
.Return(theRegistry);
theCommand = new AliasCommand();
}
示例8: SetUp
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);
}
示例9: SetUp
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);
}