Ejemplo n.º 1
0
        public void CanReadAndWriteFiles()
        {
            string dir           = "/content_parent/content_test";
            string content       = "some test content!@#$;\n\rtaenstałąż";
            int    contentLength = Encoding.UTF8.GetBytes(content).Length;

            VolumeFile volumeFile = TestVolume.CreateFile(VolumePath.FromString(dir));

            Assert.AreEqual(0, volumeFile.ReadAll().Bytes.Length);
            Assert.AreEqual("", volumeFile.ReadAll().String);

            Assert.IsTrue(volumeFile.Write(content));
            Assert.AreEqual(FileCategory.ASCII, volumeFile.ReadAll().Category);

            Assert.AreEqual(contentLength, TestVolume.Size);

            if (ExpectedCapacity != Volume.INFINITE_CAPACITY)
            {
                Assert.AreEqual(ExpectedCapacity - contentLength, TestVolume.FreeSpace);
            }
            else
            {
                Assert.AreEqual(Volume.INFINITE_CAPACITY, TestVolume.FreeSpace);
            }

            Assert.AreEqual(contentLength, volumeFile.Size);
            Assert.AreEqual(content, volumeFile.ReadAll().String);

            // we should be able to save the same file again
            Assert.IsTrue(TestVolume.SaveFile(volumeFile) != null);
        }