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); }
public void CanFailWhenSavingFileOverDirectory() { string parent1 = "/parent1"; string file1 = parent1 + "/sub1"; TestVolume.CreateDirectory(VolumePath.FromString(file1)); TestVolume.SaveFile(VolumePath.FromString(file1), new FileContent()); }