コード例 #1
0
        public void MockFileStream_Flush_WritesByteToFile()
        {
            // Arrange
            var filepath   = XFS.Path(@"c:\something\foo.txt");
            var filesystem = new MockFileSystem(new Dictionary <string, MockFileData>());
            var cut        = new MockFileStream(filesystem, filepath, MockFileStream.StreamType.WRITE);

            // Act
            cut.WriteByte(255);
            cut.Flush();

            // Assert
            CollectionAssert.AreEqual(new byte[] { 255 }, filesystem.GetFile(filepath).Contents);
        }
コード例 #2
0
        public void MockFileStream_Flush_WritesByteToFile()
        {
            // Arrange
            var filepath   = XFS.Path(@"c:\something\foo.txt");
            var filesystem = new MockFileSystem(new Dictionary <string, MockFileData>());
            var cut        = new MockFileStream(filesystem, filepath);

            // Act
            cut.WriteByte(255);
            cut.Flush();

            // Assert
            filesystem.GetFile(filepath).Contents.ShouldBeEquivalentTo(new byte[] { 255 }, options => options.WithStrictOrdering());
        }
コード例 #3
0
        public void MockFileStream_Flush_WritesByteToFile()
        {
            // Arrange
            var filepath = XFS.Path(@"c:\something\foo.txt");
            var filesystem = new MockFileSystem(new Dictionary<string, MockFileData>());
            var cut = new MockFileStream(filesystem, filepath);

            // Act
            cut.WriteByte(255);
            cut.Flush();

            // Assert
            CollectionAssert.AreEqual(new byte[]{255}, filesystem.GetFile(filepath).Contents);
        }
コード例 #4
0
        public void MockFileStream_Flush_WritesByteToFile()
        {
            // Arrange
            string         filepath   = XFS.Path(@"c:\something\foo.txt");
            MockFileSystem filesystem = new MockFileSystem(new Dictionary <string, MockFileData>());
            MockFileStream cut        = new MockFileStream(filesystem, filepath);

            // Act
            cut.WriteByte(255);
            cut.Flush();

            // Assert
            Assert.Equal(new byte[] { 255 }, filesystem.GetFile(filepath).Contents);
        }
コード例 #5
0
        public void MockFileStream_Constructor_ReadTypeNotWritable()
        {
            // Arrange
            var filePath   = @"C:\test.txt";
            var fileSystem = new MockFileSystem(new Dictionary <string, MockFileData>
            {
                { filePath, new MockFileData("hi") }
            });

            // Act
            var stream = new MockFileStream(fileSystem, filePath, MockFileStream.StreamType.READ);

            Assert.IsFalse(stream.CanWrite);
            Assert.Throws <NotSupportedException>(() => stream.WriteByte(1));
        }