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


C# MockContent.GetMockData方法代码示例

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


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

示例1: CopyToAsync_CallWithMockContent_MockContentMethodCalled

        public async Task CopyToAsync_CallWithMockContent_MockContentMethodCalled()
        {
            var content = new MockContent(MockOptions.CanCalculateLength);
            var m = new MemoryStream();

            await content.CopyToAsync(m);

            Assert.Equal(1, content.SerializeToStreamAsyncCount);
            Assert.Equal(content.GetMockData(), m.ToArray());
        }
开发者ID:nnyamhon,项目名称:corefx,代码行数:10,代码来源:HttpContentTest.cs

示例2: CopyToAsync_UseStreamWriteByteWithBufferSizeSmallerThanContentSize_ThrowsHttpRequestException

 public async Task CopyToAsync_UseStreamWriteByteWithBufferSizeSmallerThanContentSize_ThrowsHttpRequestException()
 {
     // MockContent uses stream.WriteByte() rather than stream.Write(): Verify that the max. buffer size
     // is also checked when using WriteByte().
     var content = new MockContent(MockOptions.UseWriteByteInCopyTo);
     await Assert.ThrowsAsync<HttpRequestException>(() => content.LoadIntoBufferAsync(content.GetMockData().Length - 1));
 }
开发者ID:nnyamhon,项目名称:corefx,代码行数:7,代码来源:HttpContentTest.cs

示例3: LoadIntoBufferAsync_BufferSizeSmallerThanContentSizeWithNullContentLength_ThrowsHttpRequestException

 public async Task LoadIntoBufferAsync_BufferSizeSmallerThanContentSizeWithNullContentLength_ThrowsHttpRequestException()
 {
     var content = new MockContent();
     await Assert.ThrowsAsync<HttpRequestException>(() => content.LoadIntoBufferAsync(content.GetMockData().Length - 1));
 }
开发者ID:nnyamhon,项目名称:corefx,代码行数:5,代码来源:HttpContentTest.cs

示例4: ReadAsStreamAsync_GetFromBufferedContent_CreateContentReadStreamCalled

        public async Task ReadAsStreamAsync_GetFromBufferedContent_CreateContentReadStreamCalled()
        {
            var content = new MockContent(MockOptions.CanCalculateLength);
            await content.LoadIntoBufferAsync();

            Stream stream = await content.ReadAsStreamAsync();

            Assert.Equal(0, content.CreateContentReadStreamCount);
            Assert.Equal(content.GetMockData().Length, stream.Length);
            Stream stream2 = await content.ReadAsStreamAsync();
            Assert.Same(stream, stream2);
            Assert.Equal(0, stream.Position);
            Assert.Equal((byte)'d', stream.ReadByte());
        }
开发者ID:nnyamhon,项目名称:corefx,代码行数:14,代码来源:HttpContentTest.cs

示例5: ReadAsStreamAsync_GetFromUnbufferedContent_CreateContentReadStreamCalledOnce

        public async Task ReadAsStreamAsync_GetFromUnbufferedContent_CreateContentReadStreamCalledOnce()
        {
            var content = new MockContent(MockOptions.CanCalculateLength);

            // Call multiple times: CreateContentReadStreamAsync() should be called only once.
            Stream stream = await content.ReadAsStreamAsync();
            stream = await content.ReadAsStreamAsync();
            stream = await content.ReadAsStreamAsync();

            Assert.Equal(1, content.CreateContentReadStreamCount);
            Assert.Equal(content.GetMockData().Length, stream.Length);
            Stream stream2 = await content.ReadAsStreamAsync();
            Assert.Same(stream, stream2);
        }
开发者ID:nnyamhon,项目名称:corefx,代码行数:14,代码来源:HttpContentTest.cs

示例6: TryComputeLength_RetrieveContentLengthFromBufferedContent_ComputeLengthIsNotCalled

        public async Task TryComputeLength_RetrieveContentLengthFromBufferedContent_ComputeLengthIsNotCalled()
        {
            var content = new MockContent();
            await content.LoadIntoBufferAsync();

            Assert.Equal(content.GetMockData().Length, content.Headers.ContentLength);
            
            // Called once to determine the size of the buffer.
            Assert.Equal(1, content.TryComputeLengthCount); 
        }
开发者ID:nnyamhon,项目名称:corefx,代码行数:10,代码来源:HttpContentTest.cs

示例7: TryComputeLength_RetrieveContentLength_ComputeLengthShouldBeCalled

        public void TryComputeLength_RetrieveContentLength_ComputeLengthShouldBeCalled()
        {
            var content = new MockContent(MockOptions.CanCalculateLength);

            Assert.Equal(content.GetMockData().Length, content.Headers.ContentLength);
            Assert.Equal(1, content.TryComputeLengthCount);
        }
开发者ID:nnyamhon,项目名称:corefx,代码行数:7,代码来源:HttpContentTest.cs

示例8: MockContent

 public async Task LoadIntoBufferAsync_BufferSizeSmallerThanContentSizeWithCalculatedContentLength_ThrowsHttpRequestException()
 {
     var content = new MockContent(MockOptions.CanCalculateLength);
     Task t = content.LoadIntoBufferAsync(content.GetMockData().Length - 1);
     await Assert.ThrowsAsync<HttpRequestException>(() => t);
 }
开发者ID:ChuangYang,项目名称:corefx,代码行数:6,代码来源:HttpContentTest.cs


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