コード例 #1
0
 public void ConstructionCreatesFileIfNotExistTest()
 {
     var wrapper = new FileWrapperStream(TemporaryFile);
     wrapper.Dispose();
     Assert.IsTrue(System.IO.File.Exists(TemporaryFile));
 }
コード例 #2
0
 public void PathNullConstructionTest()
 {
     var wrapper = new FileWrapperStream(null);
     wrapper.Dispose();
 }
コード例 #3
0
 public void PathRelativeConstructionTest()
 {
     var wrapper = new FileWrapperStream(System.IO.Path.Combine("..", "..", "Place", "Foo"));
     wrapper.Dispose();
 }
コード例 #4
0
 public void PathEmptyConstructionTest()
 {
     var wrapper = new FileWrapperStream(string.Empty);
     wrapper.Dispose();
 }
コード例 #5
0
        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();
        }
コード例 #6
0
        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);
        }
コード例 #7
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));
     }
 }
コード例 #8
0
 public void CanSetLength()
 {
     var wrapper = new FileWrapperStream(TemporaryFile);
     Assert.AreEqual(0, wrapper.Length);
     wrapper.SetLength(200);
     Assert.AreEqual(200, wrapper.Length);
     wrapper.Dispose();
 }