public void OpenWriteWithNotExistingFile() { // Setup var file = new TestFile(@"x:\directory\File.xml"); // Execute using (var stream = file.OpenWrite()) { var writer = new StreamWriter(stream); writer.Write("Some data."); writer.Flush(); // Assert Assert.IsTrue(file.Exists); // File was created on write. Assert.IsNotNull(stream); Assert.IsTrue(stream.Length > 0); } // Assert using (var stream = file.OpenRead()) { var reader = new StreamReader(stream); Assert.AreEqual("Some data.", reader.ReadToEnd()); } }
public void OpenWriteWithNotExistingFile() { // Setup var file = new TestFile(@"x:\directory\File.xml"); // Execute using (var stream = file.OpenWrite()) { var writer = new StreamWriter(stream); writer.Write("Some data."); writer.Flush(); // Assert Assert.IsTrue(file.Exists); // File was created on write. Assert.IsNotNull(stream); Assert.IsTrue(stream.Length > 0); } // Assert using (var stream = file.OpenRead()) { var reader = new StreamReader(stream); Assert.AreEqual("Some data.", reader.ReadToEnd()); } }