public virtual void TestWriteNewFile() { OutputStream fos = new AtomicFileOutputStream(DstFile); NUnit.Framework.Assert.IsFalse(DstFile.Exists()); fos.Write(Sharpen.Runtime.GetBytesForString(TestString)); fos.Flush(); NUnit.Framework.Assert.IsFalse(DstFile.Exists()); fos.Close(); NUnit.Framework.Assert.IsTrue(DstFile.Exists()); string readBackData = DFSTestUtil.ReadFile(DstFile); NUnit.Framework.Assert.AreEqual(TestString, readBackData); }
public virtual void TestOverwriteFile() { NUnit.Framework.Assert.IsTrue("Creating empty dst file", DstFile.CreateNewFile()); OutputStream fos = new AtomicFileOutputStream(DstFile); NUnit.Framework.Assert.IsTrue("Empty file still exists", DstFile.Exists()); fos.Write(Sharpen.Runtime.GetBytesForString(TestString)); fos.Flush(); // Original contents still in place NUnit.Framework.Assert.AreEqual(string.Empty, DFSTestUtil.ReadFile(DstFile)); fos.Close(); // New contents replace original file string readBackData = DFSTestUtil.ReadFile(DstFile); NUnit.Framework.Assert.AreEqual(TestString, readBackData); }