public void ConstructionCreatesFileIfNotExistTest()
 {
     var wrapper = new FileWrapperStream(TemporaryFile);
     wrapper.Dispose();
     Assert.IsTrue(System.IO.File.Exists(TemporaryFile));
 }
 public void PathNullConstructionTest()
 {
     var wrapper = new FileWrapperStream(null);
     wrapper.Dispose();
 }
 public void PathRelativeConstructionTest()
 {
     var wrapper = new FileWrapperStream(System.IO.Path.Combine("..", "..", "Place", "Foo"));
     wrapper.Dispose();
 }
 public void PathEmptyConstructionTest()
 {
     var wrapper = new FileWrapperStream(string.Empty);
     wrapper.Dispose();
 }
        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 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 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();
 }