private AppConfiguration LoadFromResource(string resourceName) { var fileName = _temp.CopyFileFromResources(resourceName); var configuration = System.Configuration.ConfigurationManager.OpenMappedExeConfiguration(new ExeConfigurationFileMap { ExeConfigFilename = fileName }, ConfigurationUserLevel.None); return((AppConfiguration)configuration.GetSection(AppConfiguration.SectionName)); }
public void ZipNotFound(string path) { using (var dir = new TempDirectory()) { dir.CopyFileFromResources("Content.zip"); var fullPath = Path.Combine(dir.Location, path); Assert.Throws <IOException>(() => FileSystemFactory.FileSystemInfoFromPath(fullPath)); } }
public void NewZipFile(string fileName) { using (var dir = new TempDirectory()) { dir.CopyFileFromResources("Content.zip"); var file = FileSystemFactory.FileSystemInfoFromPath(Path.Combine(dir.Location, fileName)); Assert.IsInstanceOf <ZipFolderFile>(file); ((IFile)file).OpenRead().Dispose(); } }
public void GetFolders() { using (var dir = new TempDirectory()) { var folder = new FileSystemFolder(dir.Location); Assert.AreEqual(0, folder.GetFolders().Count()); File.WriteAllText(Path.Combine(dir.Location, "11.txt"), string.Empty); dir.CopyFileFromResources("Content.zip"); Directory.CreateDirectory(Path.Combine(dir.Location, "22.txt")); Directory.CreateDirectory(Path.Combine(dir.Location, "33")); var folders = folder.GetFolders().ToArray(); CollectionAssert.AreEquivalent(new[] { "22.txt", "33", "Content.zip" }, folders.Select(i => i.Name).ToArray()); } }
public void NewZipFolder(string path, string fileName) { using (var dir = new TempDirectory()) { dir.CopyFileFromResources("Content.zip"); var folder = FileSystemFactory.FileSystemInfoFromPath(Path.Combine(dir.Location, path)); Assert.IsNotNull(folder); var files = ((IFolder)folder).GetFiles().ToList(); if (fileName != null) { Assert.AreEqual(1, files.Count); Assert.AreEqual(fileName, files[0].Name); } } }
public void BeforeEachTest() { _temp = new TempDirectory(); _temp.CopyFileFromResources("Content.zip"); _sut = new ZipFolder(Path.Combine(_temp.Location, "Content.zip")); }