本文整理汇总了C#中TestStream.SetLength方法的典型用法代码示例。如果您正苦于以下问题:C# TestStream.SetLength方法的具体用法?C# TestStream.SetLength怎么用?C# TestStream.SetLength使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TestStream
的用法示例。
在下文中一共展示了TestStream.SetLength方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: When_reading_a_truncated_PDB_with_a_valid_index
public async Task When_reading_a_truncated_PDB_with_a_valid_index()
{
var ms = new MemoryStream();
var stream = new TestStream(ms);
var didReadStream = false;
await stream.WriteAsync(Pdbs.NoSrcSrv, 0, Pdbs.NoSrcSrv.Length);
stream.Position = 0;
await Assert.ThrowsAsync<Pdb70LoadException>(async () =>
{
try
{
using (var f = await Pdb70File.TryOpenAsync(stream))
{
didReadStream = true;
// Now that the index has been read cause the next stream
// to fail to read.
stream.SetLength(stream.Length / 2);
for (var i = 0; i < f.StreamCount; i++)
{
using (var s = f.GetStream(i))
{
var b = new byte[s.Length];
await s.ReadAsync(b, 0, b.Length);
}
}
}
}
catch (Pdb70LoadException e)
{
if (!didReadStream) Assert.True(false, "The PDB read failed at the incorrect time.");
Assert.Equal(Pdb70LoadErrorCode.AssumedCorrupt, e.ErrorCode);
throw;
}
});
}