public void ConstructionCreatesFileIfNotExistTest() { var wrapper = new FileWrapperStream(TemporaryFile); wrapper.Dispose(); Assert.IsTrue(System.IO.File.Exists(TemporaryFile)); }
internal void PositionSet([PexAssumeUnderTest] FileWrapperStream target, long value) { target.Position = value; // TODO: add assertions to method FileWrapperStreamTest.PositionSet(FileWrapperStream, Int64) Assert.IsTrue(target.Position >= 0); Assert.AreEqual(value, target.Position); }
public void FlushAllTest() { int no = 4; string path; FileWrapperStream[] streams = new FileWrapperStream[no]; string dataString = "Blah"; byte[] data = StrToByteArray(dataString); for (int i = 0; i < no; i++) { path = System.IO.Path.Combine(AppContext.BaseTestDirectory, "Foo" + i + ".xml"); streams[i] = (FileWrapperStream)AppContext.StreamManager.GetStream(path); Assert.IsFalse(streams[i].IsAwaitingDiskFlush); streams[i].Write(data, 0, data.Length); Assert.IsTrue(streams[i].IsAwaitingDiskFlush); } AppContext.StreamManager.FlushAll(); for (int i = 0; i < no; i++) { Assert.IsFalse(streams[i].IsAwaitingDiskFlush); } //delete files after test for (int i = 0; i < no; i++) { path = System.IO.Path.Combine(AppContext.BaseTestDirectory, "Foo" + i + ".xml"); (new FileInfo(path)).Delete(); } }
public void ConstructionFailsIfFileIfCannotOpenFile() { using (System.IO.BinaryWriter writer = new System.IO.BinaryWriter(new System.IO.FileStream(TemporaryFile, System.IO.FileMode.OpenOrCreate))) { var wrapper = new FileWrapperStream(TemporaryFile); wrapper.Dispose(); Assert.IsTrue(System.IO.File.Exists(TemporaryFile)); } }
public void CanSetLength() { var wrapper = new FileWrapperStream(TemporaryFile); Assert.AreEqual(0, wrapper.Length); wrapper.SetLength(200); Assert.AreEqual(200, wrapper.Length); wrapper.Dispose(); }
public static FileWrapperStream Create(string path_s) { FileWrapperStream fileWrapperStream = new FileWrapperStream(path_s); return fileWrapperStream; // TODO: Edit factory method of FileWrapperStream // This method should be able to configure the object in all possible ways. // Add as many parameters as needed, // and assign their values to each field by using the API. }
public void WriteSetsDiskFlushFlag() { using (var wrapper = new FileWrapperStream(TemporaryFile)) { wrapper.Seek(0, System.IO.SeekOrigin.Begin); Assert.IsFalse(wrapper.IsAwaitingDiskFlush); wrapper.WriteByte(4); Assert.IsTrue(wrapper.IsAwaitingDiskFlush); } }
public static FileWrapperStream Create(string path_s) { FileWrapperStream fileWrapperStream = new FileWrapperStream(path_s); return(fileWrapperStream); // TODO: Edit factory method of FileWrapperStream // This method should be able to configure the object in all possible ways. // Add as many parameters as needed, // and assign their values to each field by using the API. }
public void FlushTest() { FileWrapperStream stream = (FileWrapperStream)AppContext.StreamManager.GetStream(TmpPath); Assert.IsFalse(stream.IsAwaitingDiskFlush); string dataString = "Blah"; byte[] data = StrToByteArray(dataString); stream.Write(data, 0, data.Length); Assert.IsTrue(stream.IsAwaitingDiskFlush); AppContext.StreamManager.Flush(TmpPath); //this should pass... file exists Assert.IsFalse(stream.IsAwaitingDiskFlush); }
public void ConstructionDoesNotEraseFileIfExistTest() { System.IO.StreamWriter writer = System.IO.File.CreateText(TemporaryFile); writer.Write("blah"); writer.Close(); System.IO.FileInfo preInfo = new System.IO.FileInfo(TemporaryFile); Assert.IsTrue(preInfo.Length != 0); var wrapper = new FileWrapperStream(TemporaryFile); wrapper.Dispose(); Assert.IsTrue(System.IO.File.Exists(TemporaryFile)); System.IO.FileInfo postInfo = new System.IO.FileInfo(TemporaryFile); Assert.IsTrue(postInfo.Length != 0); }
public void WriteToNonExistingFileTest() { Assert.IsFalse(System.IO.File.Exists(TemporaryFile)); using (var wrapper = new FileWrapperStream(TemporaryFile)) { Assert.IsFalse(wrapper.IsAwaitingDiskFlush); System.IO.StreamWriter writer = new System.IO.StreamWriter(wrapper); writer.AutoFlush = true; writer.Write("test"); } using (System.IO.StreamReader reader = new System.IO.StreamReader(TemporaryFile)) { string data = reader.ReadToEnd(); Assert.AreEqual("test", data); } }
public void LoadExistingFileTest() { System.IO.StreamWriter writer = System.IO.File.CreateText(TemporaryFile); writer.Write("blah"); writer.Close(); var wrapper = new FileWrapperStream(TemporaryFile); // Ensure that new FileWrappers start at the beginning Assert.AreEqual(0, wrapper.Position); Assert.AreEqual(4, wrapper.Length); wrapper.Position = 0; System.IO.StreamReader reader = new System.IO.StreamReader(wrapper); string data = reader.ReadToEnd(); Assert.AreEqual("blah", data); wrapper.Dispose(); }
public void WriteToExistingFileTest() { using (System.IO.StreamWriter writer = System.IO.File.CreateText(TemporaryFile)) { writer.Write("blah"); writer.Close(); } using (var wrapper = new FileWrapperStream(TemporaryFile)) { wrapper.Seek(0, System.IO.SeekOrigin.End); Assert.IsFalse(wrapper.IsAwaitingDiskFlush); System.IO.StreamWriter writer = new System.IO.StreamWriter(wrapper); writer.AutoFlush = true; writer.Write("test"); } using (System.IO.StreamReader reader = new System.IO.StreamReader(TemporaryFile)) { string data = reader.ReadToEnd(); Assert.AreEqual("blahtest", data); } }
internal void WriteByte([PexAssumeUnderTest] FileWrapperStream target, byte value) { target.WriteByte(value); // TODO: add assertions to method FileWrapperStreamTest.WriteByte(FileWrapperStream, Byte) }
public void PathRelativeConstructionTest() { var wrapper = new FileWrapperStream(System.IO.Path.Combine("..", "..", "Place", "Foo")); wrapper.Dispose(); }
public void PathNullConstructionTest() { var wrapper = new FileWrapperStream(null); wrapper.Dispose(); }
public void PathEmptyConstructionTest() { var wrapper = new FileWrapperStream(string.Empty); wrapper.Dispose(); }