本文整理汇总了C#中MockFile.ReadAllBytes方法的典型用法代码示例。如果您正苦于以下问题:C# MockFile.ReadAllBytes方法的具体用法?C# MockFile.ReadAllBytes怎么用?C# MockFile.ReadAllBytes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MockFile
的用法示例。
在下文中一共展示了MockFile.ReadAllBytes方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MockFile_AppendAllText_ShouldPersistNewTextWithCustomEncoding
public void MockFile_AppendAllText_ShouldPersistNewTextWithCustomEncoding()
{
// Arrange
const string 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", Encoding.BigEndianUnicode);
// Assert
var expected = new byte[]
{
68, 101, 109, 111, 32, 116, 101, 120, 116, 32, 99, 111, 110, 116,
101, 110, 255, 253, 0, 43, 0, 32, 0, 115, 0, 111, 0, 109, 0, 101,
0, 32, 0, 116, 0, 101, 0, 120, 0, 116
};
CollectionAssert.AreEqual(
expected,
file.ReadAllBytes(path));
}
示例2: MockFile_ReadAllBytes_ShouldReturnOriginalByteData
public void MockFile_ReadAllBytes_ShouldReturnOriginalByteData()
{
// 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.ReadAllBytes(@"c:\something\other.gif");
// Assert
CollectionAssert.AreEqual(
new byte[] { 0x21, 0x58, 0x3f, 0xa9 },
result);
}