예제 #1
0
        public async Task CannotWriteToUnwritableFile()
        {
            var no = new SpecialFile(NoPermsPath);
            await no.Commit("test");

            Assert.AreEqual("", no.Contents);
        }
예제 #2
0
        public void CanDeleteNonExistentFile()
        {
            Assert.IsFalse(File.Exists(NoExistsPath));
            var no = new SpecialFile(NoExistsPath);

            no.Delete();
            Assert.DoesNotThrow(() => no.Delete());
        }
예제 #3
0
        public void CanCheckExists()
        {
            var exists   = new SpecialFile(ExistsPath);
            var noExists = new SpecialFile(NoExistsPath);

            Assert.IsTrue(exists.Exists);
            Assert.IsFalse(noExists.Exists);
        }
예제 #4
0
        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]);
        }
예제 #5
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));
        }
예제 #6
0
        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]);
     }
 }
예제 #9
0
        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));
        }
예제 #10
0
        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
            };
        }
예제 #11
0
        public void PermissionsToNonExistingFile()
        {
            var noExists = new SpecialFile(NoExistsPath);

            Assert.IsTrue(noExists.HasPermission);
        }
예제 #12
0
        public void NoPermissionsWithReadOnlyFile()
        {
            var noWrite = new SpecialFile(NoPermsPath);

            Assert.IsFalse(noWrite.HasPermission);
        }
예제 #13
0
        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");
 }