Beispiel #1
0
 public void WhenSwappingFromMemoryBufferToFileBufferMemoryBufferShouldBeMigrated()
 {
     using (var bufferedFileStream = new MemoryStreamWithFileBacking(6))
     {
         bufferedFileStream.Write(Encoding.UTF8.GetBytes("HELLO"), 0, 5);
         bufferedFileStream.Write(Encoding.UTF8.GetBytes(" WORLD"), 0, 6);
         bufferedFileStream.Flush();
         Assert.IsTrue(File.Exists(bufferedFileStream.BackingFilePath));
     }
 }
 public void WhenSwappingFromMemoryBufferToFileBufferMemoryBufferShouldBeMigrated()
 {
     using (var bufferedFileStream = new MemoryStreamWithFileBacking(6))
     {
         bufferedFileStream.Write(Encoding.UTF8.GetBytes("HELLO"), 0, 5);
         bufferedFileStream.Write(Encoding.UTF8.GetBytes(" WORLD"), 0, 6);
         bufferedFileStream.Flush();
         Assert.IsTrue(File.Exists(bufferedFileStream.BackingFilePath));
     }
 }
        public void MemoryShouldBeFlushedWhenBufferLimitExceeded()
        {
            using (var bufferedFileStream = new MemoryStreamWithFileBacking(4))
            {
                bufferedFileStream.Write(Encoding.UTF8.GetBytes("HELLO"), 0, 5);
                bufferedFileStream.Flush();

                Assert.IsTrue(File.Exists(bufferedFileStream.BackingFilePath));
            }
        }
Beispiel #4
0
        public void MemoryShouldBeFlushedWhenBufferLimitExceeded()
        {
            using (var bufferedFileStream = new MemoryStreamWithFileBacking(4))
            {
                bufferedFileStream.Write(Encoding.UTF8.GetBytes("HELLO"), 0, 5);
                bufferedFileStream.Flush();

                Assert.IsTrue(File.Exists(bufferedFileStream.BackingFilePath));
            }
        }
Beispiel #5
0
        public void MemoryShouldNotBeFlushUntilBufferLimitReached()
        {
            using (var bufferedFileStream = new MemoryStreamWithFileBacking(6))
            {
                bufferedFileStream.Write(Encoding.UTF8.GetBytes("HELLO"), 0, 5);
                bufferedFileStream.Flush();

                Assert.IsFalse(File.Exists(bufferedFileStream.BackingFilePath));
            }
        }
        public void MemoryShouldNotBeFlushUntilBufferLimitReached()
        {
            using (var bufferedFileStream = new MemoryStreamWithFileBacking(6))
            {
                bufferedFileStream.Write(Encoding.UTF8.GetBytes("HELLO"), 0, 5);
                bufferedFileStream.Flush();
                
                Assert.IsFalse(File.Exists(bufferedFileStream.BackingFilePath));
            }

        }
        public void BackingFileShouldBeRemovedWhenDisposed()
        {
            string backingFileName;

            using (var bufferedFileStream = new MemoryStreamWithFileBacking(1))
            {
                bufferedFileStream.Write(Encoding.UTF8.GetBytes("HELLO"), 0, 5);
                bufferedFileStream.Flush();

                backingFileName = bufferedFileStream.BackingFilePath;

                Assert.IsTrue(File.Exists(backingFileName));
            }

            Assert.IsFalse(File.Exists(backingFileName));
        }
Beispiel #8
0
        public void BackingFileShouldBeRemovedWhenDisposed()
        {
            string backingFileName;

            using (var bufferedFileStream = new MemoryStreamWithFileBacking(1))
            {
                bufferedFileStream.Write(Encoding.UTF8.GetBytes("HELLO"), 0, 5);
                bufferedFileStream.Flush();

                backingFileName = bufferedFileStream.BackingFilePath;

                Assert.IsTrue(File.Exists(backingFileName));
            }

            Assert.IsFalse(File.Exists(backingFileName));
        }