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


C# MockFile.ReadAllText方法代码示例

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


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

示例1: MockFile_AppendAllLines_ShouldPersistNewLinesToNewFile

        public void MockFile_AppendAllLines_ShouldPersistNewLinesToNewFile()
        {
            // Arrange
            string path = XFS.Path(@"c:\something\demo.txt");
            var fileSystem = new MockFileSystem(new Dictionary<string, MockFileData>
            {
                { XFS.Path(@"c:\something\"), new MockDirectoryData() }
            });
            var file = new MockFile(fileSystem);

            // Act
            file.AppendAllLines(path, new[] { "line 1", "line 2", "line 3" });

            // Assert
            Assert.AreEqual(
                "line 1" + Environment.NewLine + "line 2" + Environment.NewLine + "line 3" + Environment.NewLine,
                file.ReadAllText(path));
        }
开发者ID:wafe,项目名称:System.IO.Abstractions,代码行数:18,代码来源:MockFileAppendAllLinesTests.cs

示例2: MockFile_AppendAllText_ShouldPersistNewText

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

            var file = new MockFile(fileSystem);

            // Act
            file.AppendAllText(path, "+ some text");

            // Assert
            Assert.AreEqual(
                "Demo text content+ some text",
                file.ReadAllText(path));
        }
开发者ID:tathamoddie,项目名称:System.IO.Abstractions,代码行数:19,代码来源:MockFileAppendAllTextTests.cs

示例3: MockFile_ReadAllText_ShouldReturnOriginalDataWithCustomEncoding

        public void MockFile_ReadAllText_ShouldReturnOriginalDataWithCustomEncoding()
        {
            // Arrange
            const string text = "Hello there!";
            var encodedText = Encoding.BigEndianUnicode.GetBytes(text);
            var fileSystem = new MockFileSystem(new Dictionary<string, MockFileData>
            {
                { @"c:\something\demo.txt", new MockFileData(encodedText) }
            });

            var file = new MockFile(fileSystem);

            // Act
            var result = file.ReadAllText(@"c:\something\demo.txt", Encoding.BigEndianUnicode);

            // Assert
            Assert.AreEqual(text, result);
        }
开发者ID:rockarts,项目名称:System.IO.Abstractions,代码行数:18,代码来源:MockFileTests.cs

示例4: MockFile_ReadAllText_ShouldReturnOriginalTextData

        public void MockFile_ReadAllText_ShouldReturnOriginalTextData()
        {
            // Arrange
            var fileSystem = new MockFileSystem(new Dictionary<string, MockFileData>
            {
                { @"c:\something\demo.txt", new MockFileData("Demo text content") },
                { @"c:\something\other.gif", new MockFileData(new byte[] { 0x21, 0x58, 0x3f, 0xa9 }) }
            });

            var file = new MockFile(fileSystem);

            // Act
            var result = file.ReadAllText(@"c:\something\demo.txt");

            // Assert
            Assert.AreEqual(
                "Demo text content",
                result);
        }
开发者ID:rockarts,项目名称:System.IO.Abstractions,代码行数:19,代码来源:MockFileTests.cs


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