public async Task CannotWriteToUnwritableFile() { var no = new SpecialFile(NoPermsPath); await no.Commit("test"); Assert.AreEqual("", no.Contents); }
public void CanDeleteNonExistentFile() { Assert.IsFalse(File.Exists(NoExistsPath)); var no = new SpecialFile(NoExistsPath); no.Delete(); Assert.DoesNotThrow(() => no.Delete()); }
public void CanCheckExists() { var exists = new SpecialFile(ExistsPath); var noExists = new SpecialFile(NoExistsPath); Assert.IsTrue(exists.Exists); Assert.IsFalse(noExists.Exists); }
public async Task CanWriteToRegularFile() { var exists = new SpecialFile(Path.GetTempFileName()); await exists.Commit("test"); Assert.AreEqual("test", await exists.Read()); Assert.AreEqual("test", exists.Contents); Assert.AreEqual("test", (await exists.Lines())[0]); }
public void CanDeleteReadOnlyFile() { var path = NoPermsPath; Assert.IsTrue(File.Exists(path)); var file = new SpecialFile(path); Assert.DoesNotThrow(() => file.Delete()); Assert.IsTrue(File.Exists(path)); }
public void CanDeleteRegularFile() { var path = ExistsPath; Assert.IsTrue(File.Exists(path)); var file = new SpecialFile(path); Assert.DoesNotThrow(() => file.Delete()); Assert.IsFalse(File.Exists(path)); }
private static string GenerateFilePath(SpecialFile specialFolder) { switch (specialFolder) { case SpecialFile.PlayerBlueprintCollection: var path = Path.Combine(AppData, "Zetta", "loadedblueprints.zetta"); return(path); default: return(""); } }
public static string GetPath(this SpecialFile specialFile) { try { return(filePathCache[specialFile]); } catch { filePathCache[specialFile] = GenerateFilePath(specialFile); return(filePathCache[specialFile]); } }
public string getPath(SpecialFile file) { ILocalFile localFile; switch (file) { case SpecialFile.DATABASE: localFile = new LocalFile(LogicalDirectory.Data, DATABASE_FILE_NAME); break; default: return(""); } return(getPath(localFile)); }
public Syscalls(WaterboxHost parent) { _parent = parent; var stdin = new SpecialFile(Stream.Null, "___stdin"); var stdout = new SpecialFile(Console.OpenStandardOutput(), "___stdout"); var stderr = new SpecialFile(Console.OpenStandardError(), "___stderr"); _openFiles = new List <IFileObject> { stdin, stdout, stderr }; _availableFiles = new Dictionary <string, IFileObject> { [stdin.Name] = stdin, [stdout.Name] = stdout, [stderr.Name] = stderr }; }
public void PermissionsToNonExistingFile() { var noExists = new SpecialFile(NoExistsPath); Assert.IsTrue(noExists.HasPermission); }
public void NoPermissionsWithReadOnlyFile() { var noWrite = new SpecialFile(NoPermsPath); Assert.IsFalse(noWrite.HasPermission); }
public void HasWritePermissionsWithWritableFile() { var canWrite = new SpecialFile(ExistsPath); Assert.IsTrue(canWrite.HasPermission); }
public VsProjectSpecialFiles(VsHierarchyFake hierarchyFake) { Fake_SettingsSpecialFile = new SpecialFile(hierarchyFake, true, @"c:\temp\WindowsApplication\My Project\Settings.settings", true, "EmbeddedResource"); Fake_ResxSpecialFile = new SpecialFile(hierarchyFake, true, @"c:\temp\WindowsApplication\My Project\Resources.resx", true, "EmbeddedResource"); Fake_AppXamlSpecialFile = new SpecialFile(hierarchyFake, true, @"c:\temp\WindowsApplication\Application.xaml", true, "ApplicationDefinition"); }