当前位置: 首页>>代码示例>>C#>>正文


C# MockFileSystem.FileExists方法代码示例

本文整理汇总了C#中MockFileSystem.FileExists方法的典型用法代码示例。如果您正苦于以下问题:C# MockFileSystem.FileExists方法的具体用法?C# MockFileSystem.FileExists怎么用?C# MockFileSystem.FileExists使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MockFileSystem的用法示例。


在下文中一共展示了MockFileSystem.FileExists方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Mockfile_Create_ShouldCreateNewStream

        public void Mockfile_Create_ShouldCreateNewStream()
        {
            string fullPath = XFS.Path(@"c:\something\demo.txt");
            var fileSystem = new MockFileSystem();

            var sut = new MockFile(fileSystem);

            Assert.That(fileSystem.FileExists(fullPath), Is.False);

            sut.Create(fullPath).Close();

            Assert.That(fileSystem.FileExists(fullPath), Is.True);
        }
开发者ID:wafe,项目名称:System.IO.Abstractions,代码行数:13,代码来源:MockFileCreateTests.cs

示例2: MockFile_Move_ShouldMoveFileWithinMemoryFileSystem

        public void MockFile_Move_ShouldMoveFileWithinMemoryFileSystem()
        {
            string sourceFilePath = XFS.Path(@"c:\something\demo.txt");
            string sourceFileContent = "this is some content";
            var fileSystem = new MockFileSystem(new Dictionary<string, MockFileData>
            {
                {sourceFilePath, new MockFileData(sourceFileContent)},
                {XFS.Path(@"c:\somethingelse\dummy.txt"), new MockFileData(new byte[] {0})}
            });

            string destFilePath = XFS.Path(@"c:\somethingelse\demo1.txt");

            fileSystem.File.Move(sourceFilePath, destFilePath);

            Assert.That(fileSystem.FileExists(destFilePath), Is.True);
            Assert.That(fileSystem.GetFile(destFilePath).TextContents, Is.EqualTo(sourceFileContent));
            Assert.That(fileSystem.FileExists(sourceFilePath), Is.False);
        }
开发者ID:ericnewton76,项目名称:System.IO.Abstractions,代码行数:18,代码来源:MockFileMoveTests.cs

示例3: MockDirectory_CreateDirectory_ShouldCreatePlaceholderFileInMemoryFileSystem

        public void MockDirectory_CreateDirectory_ShouldCreatePlaceholderFileInMemoryFileSystem()
        {
            // Arrange
            var fileSystem = new MockFileSystem(new Dictionary<string, MockFileData>
            {
                { @"c:\foo.txt", new MockFileData("Demo text content") }
            });

            // Act
            fileSystem.Directory.CreateDirectory(@"c:\bar");

            // Assert
            Assert.IsTrue(fileSystem.FileExists(@"c:\bar\__PLACEHOLDER__.dir"));
        }
开发者ID:juanplopes,项目名称:io-abstractions,代码行数:14,代码来源:MockDirectoryTests.cs

示例4: MockDirectory_CreateDirectory_ShouldCreateFolderInMemoryFileSystem

        public void MockDirectory_CreateDirectory_ShouldCreateFolderInMemoryFileSystem()
        {
            // Arrange
            var fileSystem = new MockFileSystem(new Dictionary<string, MockFileData>
            {
                { XFS.Path(@"c:\foo.txt"), new MockFileData("Demo text content") }
            });

            // Act
            fileSystem.Directory.CreateDirectory(XFS.Path(@"c:\bar"));

            // Assert
            Assert.IsTrue(fileSystem.FileExists(XFS.Path(@"c:\bar\")));
            Assert.IsTrue(fileSystem.AllDirectories.Any(d => d == XFS.Path(@"c:\bar\")));
        }
开发者ID:tathamoddie,项目名称:System.IO.Abstractions,代码行数:15,代码来源:MockDirectoryTests.cs

示例5: MockFile_Delete_ShouldRemoveFileFromFileSystem

        public void MockFile_Delete_ShouldRemoveFileFromFileSystem()
        {
            const string fullPath = @"c:\something\demo.txt";
            var fileSystem = new MockFileSystem(new Dictionary<string, MockFileData>
            {
                { fullPath, new MockFileData("Demo text content") }
            });

            var file = new MockFile(fileSystem);

            file.Delete(fullPath);

            Assert.That(fileSystem.FileExists(fullPath), Is.False);
        }
开发者ID:pranavkm,项目名称:System.IO.Abstractions,代码行数:14,代码来源:MockFileTests.cs

示例6: MockFile_OpenWrite_ShouldOverwriteExistingFiles

        public void MockFile_OpenWrite_ShouldOverwriteExistingFiles()
        {
            const string filePath = @"c:\something\demo.txt";
            const string startFileContent = "this is some content";
            const string endFileContent = "this is some other content";
            var fileSystem = new MockFileSystem(new Dictionary<string, MockFileData>
            {
                {filePath, new MockFileData(startFileContent)}
            });

            var bytes = new UTF8Encoding(true).GetBytes(endFileContent);
            var stream = fileSystem.File.OpenWrite(filePath);
            stream.Write(bytes, 0, bytes.Length);
            stream.Close();

            Assert.That(fileSystem.FileExists(filePath), Is.True);
            Assert.That(fileSystem.GetFile(filePath).TextContents, Is.EqualTo(endFileContent));
        }
开发者ID:pranavkm,项目名称:System.IO.Abstractions,代码行数:18,代码来源:MockFileTests.cs

示例7: MockFile_OpenWrite_ShouldCreateNewFiles

        public void MockFile_OpenWrite_ShouldCreateNewFiles() {
            const string filePath = @"c:\something\demo.txt";
            const string fileContent = "this is some content";
            var fileSystem = new MockFileSystem();

            var bytes = new UTF8Encoding(true).GetBytes(fileContent);
            var stream = fileSystem.File.OpenWrite(filePath);
            stream.Write(bytes, 0, bytes.Length);
            stream.Close();

            Assert.That(fileSystem.FileExists(filePath), Is.True);
            Assert.That(fileSystem.GetFile(filePath).TextContents, Is.EqualTo(fileContent));
        }
开发者ID:pranavkm,项目名称:System.IO.Abstractions,代码行数:13,代码来源:MockFileTests.cs

示例8: MockFile_AppendText_CreatesNewFileForAppendToNonExistingFile

        public void MockFile_AppendText_CreatesNewFileForAppendToNonExistingFile()
        {
            string filepath = XFS.Path(@"c:\something\doesnt\exist.txt");
            var filesystem = new MockFileSystem(new Dictionary<string, MockFileData>());

            var stream = filesystem.File.AppendText(filepath);

            stream.Write("New too!");
            stream.Flush();
            stream.Close();

            var file = filesystem.GetFile(filepath);
            Assert.That(file.TextContents, Is.EqualTo("New too!"));
            Assert.That(filesystem.FileExists(filepath));
        }
开发者ID:ericnewton76,项目名称:System.IO.Abstractions,代码行数:15,代码来源:MockFileTests.cs

示例9: GetTempFileName_Called_CreatesEmptyFileInTempDirectory

        public void GetTempFileName_Called_CreatesEmptyFileInTempDirectory()
        {
            //Arrange
            var fileSystem = new MockFileSystem();
            var mockPath = new MockPath(fileSystem);

            //Creating directory explicitly because in normal system Tempory path always exist.
            fileSystem.Directory.CreateDirectory(mockPath.GetTempPath());

            //Act
            var result = mockPath.GetTempFileName();

            Assert.True(fileSystem.FileExists(result));
            Assert.AreEqual(0, fileSystem.FileInfo.FromFileName(result).Length);
        }
开发者ID:BrianLanghoor,项目名称:System.IO.Abstractions,代码行数:15,代码来源:MockPathTests.cs

示例10: Mockfile_Create_ShouldCreateNewStream

        public void Mockfile_Create_ShouldCreateNewStream()
        {
            const string fullPath = @"c:\something\demo.txt";
            var fileSystem = new MockFileSystem(new Dictionary<string, MockFileData>());

            var sut = new MockFile(fileSystem);

            Assert.That(fileSystem.FileExists(fullPath), Is.False);

            sut.Create(fullPath).Close();

            Assert.That(fileSystem.FileExists(fullPath), Is.True);
        }
开发者ID:parshim,项目名称:System.IO.Abstractions,代码行数:13,代码来源:MockFileTests.cs

示例11: GetTempFileName_Called_CreatesEmptyFileInTempDirectory

        public void GetTempFileName_Called_CreatesEmptyFileInTempDirectory()
        {
            //Arrange
            var fileSystem = new MockFileSystem();
            var mockPath = new MockPath(fileSystem);

            //Act
            var result = mockPath.GetTempFileName();

            Assert.True(fileSystem.FileExists(result));
            Assert.AreEqual(0, fileSystem.FileInfo.FromFileName(result).Length);
        }
开发者ID:tathamoddie,项目名称:System.IO.Abstractions,代码行数:12,代码来源:MockPathTests.cs


注:本文中的MockFileSystem.FileExists方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。