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


C# TestStream.WriteAsync方法代码示例

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


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

示例1: When_reading_a_file_with_source_server_information

        public async Task When_reading_a_file_with_source_server_information()
        {
            var sut = new Pdb70SymbolMetadataProvider();

            var ms = new MemoryStream();
            var stream = new TestStream(ms);
            await stream.WriteAsync(Pdbs.RealSrcSrv, 0, Pdbs.RealSrcSrv.Length);
            stream.Position = 0;

            using (var metadata = await sut.TryGetSymbolMetadataAsync(stream))
            {
                Assert.NotNull(metadata);
                Assert.True(metadata.SupportsSourceServerInformation);
                Assert.Equal("63ba9bb5992dfc429f6bcc52135dbb092", metadata.Identifier);
                Assert.True(metadata.HasSourceServerInformation);
                Assert.Equal(581, metadata.SourceInformation.Count);
                Assert.False(metadata.SourceInformation.Any(x => string.IsNullOrEmpty(x.TargetPath)));
            }
        }
开发者ID:tmr232,项目名称:symblr,代码行数:19,代码来源:Pdb70SymbolMetadataProviderFixtures.cs

示例2: When_writing_to_a_PDB_with_no_source_server_stream

        public async Task When_writing_to_a_PDB_with_no_source_server_stream()
        {
            var longString = new StringBuilder();
            for (var i = 0; i < 1000; i++)
                longString.AppendFormat("Line {0}", i).AppendLine();

            var ms = new MemoryStream();
            var stream = new TestStream(ms);
            await stream.WriteAsync(Pdbs.NoSrcSrv, 0, Pdbs.NoSrcSrv.Length);
            stream.Position = 0;

            using (var file = await Pdb70File.TryOpenAsync(stream))
            {
                using (var srcsrv = file.GetStream("SRCSRV"))
                using (var writer = new StreamWriter(srcsrv))
                {
                    await writer.WriteAsync(longString.ToString());
                    await writer.FlushAsync();
                }

                await file.SaveAsync();

                stream = new TestStream(ms.ToArray());
                stream.Position = 0;
            }

            using (var file = await Pdb70File.TryOpenAsync(stream))
            {
                using (var srcsrv = file.GetStream("SRCSRV"))
                using (var reader = new StreamReader(srcsrv))
                {
                    var data = await reader.ReadToEndAsync();
                    Assert.Equal(longString.ToString(), data);
                }
            }
        }
开发者ID:tmr232,项目名称:symblr,代码行数:36,代码来源:Pdb70FileFixtures.cs

示例3: When_an_exception_is_thrown_during_reading

        public async Task When_an_exception_is_thrown_during_reading()
        {
            var ms = new MemoryStream();
            var stream = new TestStream(ms);
            await stream.WriteAsync(Pdbs.SrcSrv, 0, Pdbs.SrcSrv.Length);
            stream.Position = 0;
            stream.ThrowAfter = 1024;

            await Assert.ThrowsAsync<Pdb70LoadException>(async () =>
            {
                try
                {
                    await Pdb70File.TryOpenAsync(stream);
                }
                catch (Pdb70LoadException e)
                {
                    Assert.Equal(Pdb70LoadErrorCode.Unknown, e.ErrorCode);
                    Assert.NotNull(e.InnerException);
                    Assert.Equal(e.InnerException.Message, "Exception from the stream.");
                    throw;
                }
            });
        }
开发者ID:tmr232,项目名称:symblr,代码行数:23,代码来源:Pdb70FileFixtures.cs

示例4: When_reading_a_PDB_with_a_deleted_header_entry

        public async Task When_reading_a_PDB_with_a_deleted_header_entry()
        {
            var ms = new MemoryStream();
            var stream = new TestStream(ms);
            await stream.WriteAsync(Pdbs.DeletedBitSet, 0, Pdbs.DeletedBitSet.Length);
            stream.Position = 0;

            await Assert.ThrowsAsync<Pdb70LoadException>(async () =>
            {
                try
                {
                    await Pdb70File.TryOpenAsync(stream);
                }
                catch (Pdb70LoadException e)
                {
                    Assert.Equal(Pdb70LoadErrorCode.UnsupportedFeature, e.ErrorCode);
                    throw;
                }
            });
        }
开发者ID:tmr232,项目名称:symblr,代码行数:20,代码来源:Pdb70FileFixtures.cs

示例5: 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;
                }
            });
        }
开发者ID:tmr232,项目名称:symblr,代码行数:38,代码来源:Pdb70FileFixtures.cs

示例6: When_reading_a_truncated_PDB

        public async Task When_reading_a_truncated_PDB()
        {
            var ms = new MemoryStream();
            var stream = new TestStream(ms);
            await stream.WriteAsync(Pdbs.NoSrcSrv, 0, Pdbs.NoSrcSrv.Length / 2);
            stream.Position = 0;

            await Assert.ThrowsAsync<Pdb70LoadException>(async () =>
            {
                try
                {
                    await Pdb70File.TryOpenAsync(stream);
                }
                catch (Pdb70LoadException e)
                {
                    Assert.Equal(Pdb70LoadErrorCode.AssumedCorrupt, e.ErrorCode);
                    throw;
                }
            });
        }
开发者ID:tmr232,项目名称:symblr,代码行数:20,代码来源:Pdb70FileFixtures.cs


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