本文整理汇总了C#中System.IO.SelectMany方法的典型用法代码示例。如果您正苦于以下问题:C# System.IO.SelectMany方法的具体用法?C# System.IO.SelectMany怎么用?C# System.IO.SelectMany使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.IO
的用法示例。
在下文中一共展示了System.IO.SelectMany方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Should_parse_integer_to_bytes
public void Should_parse_integer_to_bytes()
{
// Arrange
var asn1Input = new[]
{
new byte[] {2, 1, 0},
new byte[] {2, 1, 127},
new byte[] {2, 2, 0, 127},
new byte[] {2, 2, 0, 128},
new byte[] {2, 3, 1, 0, 0},
new byte[] {2, 0},
new byte[] {2, 7, 0, 165, 163, 214, 2, 169, 62}
}.Select(b => new MemoryStream(b));
var expectedParsedValues = new[]
{
new byte[] {0},
new byte[] {127},
new byte[] {0, 127},
new byte[] {128},
new byte[] {1, 0, 0},
new byte[0],
new byte[] {165, 163, 214, 2, 169, 62} //TODO as far as I undertand, it is correct that the parser removes the leading zero here. However, when parsing a PEM this must be taken into account and the parser must pad the parsed value with a leading zero
};
var sut = new Asn1Parser();
// Act
var result = asn1Input.SelectMany(sut.Parse).Cast<Integer>().Select(i => i.UnencodedValue).ToArray();
// Assert
result.Length.Should().Be(expectedParsedValues.Length);
for (int i = 0; i < expectedParsedValues.Length; i++)
{
result[i].Should().Equal(expectedParsedValues[i]);
}
}