Ejemplo n.º 1
0
        public void FileManipulation()
        {
            using var pfs = new PhysFS("");
            pfs.SetWriteDir("./");
            pfs.Mount("./", "/", true);

            using (var sw = new StreamWriter(pfs.OpenWrite("foo")))
            {
                sw.Write("hello, world! èòàùã こんにちは世界 你好世界");
            }

            Assert.True(File.Exists("./foo"));

            var fileContent = File.ReadAllText("./foo");

            using (var sr = new StreamReader(pfs.OpenRead("foo")))
            {
                sr.ReadToEnd().Should().BeEquivalentTo(fileContent);
            }

            using (var sw = new StreamWriter(pfs.OpenAppend("foo")))
            {
                sw.Write("foo");
            }
            File.ReadAllText("./foo").Should().BeEquivalentTo(fileContent + "foo");

            pfs.Delete("foo");
            Assert.False(File.Exists("./foo"));
        }