本文整理汇总了C#中HttpResponseStream.Seek方法的典型用法代码示例。如果您正苦于以下问题:C# HttpResponseStream.Seek方法的具体用法?C# HttpResponseStream.Seek怎么用?C# HttpResponseStream.Seek使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HttpResponseStream
的用法示例。
在下文中一共展示了HttpResponseStream.Seek方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Read_PastEndOfStream_ReturnsAmountRead
public void Read_PastEndOfStream_ReturnsAmountRead()
{
var stream = new HttpResponseStream ();
var buffer = new byte [10];
stream.Write (buffer, 0, 10);
stream.Seek (-1, SeekOrigin.End);
int amount_read = stream.Read (buffer, 0, 2);
Assert.AreEqual (1, amount_read);
}
示例2: Read_ReadLastItem_UpdatesPosition
public void Read_ReadLastItem_UpdatesPosition()
{
var stream = new HttpResponseStream ();
var buffer = new byte [10];
stream.Write (buffer, 0, 10);
stream.Seek (-1, SeekOrigin.End);
stream.Read (buffer, 0, 1);
long position = stream.Position;
Assert.AreEqual (10, position);
}
示例3: Read_MultipleBuffers_UpdatesPosition
public void Read_MultipleBuffers_UpdatesPosition()
{
var stream = new HttpResponseStream ();
var buffer = new byte [10];
stream.Write (buffer, 0, 10);
stream.Write (buffer, 0, 10);
stream.Write (buffer, 0, 10);
stream.Seek (15, SeekOrigin.Begin);
stream.Read (buffer, 0, 5);
long position = stream.Position;
Assert.AreEqual (20, position);
}
示例4: Read_MultipleBuffers_CorrectData
public void Read_MultipleBuffers_CorrectData()
{
var stream = new HttpResponseStream ();
var write_buffer1 = new byte [3];
var write_buffer2 = new byte [3];
var read_buffer = new byte [6];
stream.Write (write_buffer1, 0, 3);
write_buffer2 [0] = 0xFA;
stream.Write (write_buffer2, 0, 3);
stream.Seek (0, SeekOrigin.Begin);
stream.Read (read_buffer, 0, 6);
byte read_byte = read_buffer [3];
Assert.AreEqual (0xFA, read_byte);
}
示例5: Write_SeekedBackPastLastSegmentWriteOverAll_SetsPosition
public void Write_SeekedBackPastLastSegmentWriteOverAll_SetsPosition()
{
var stream = new HttpResponseStream ();
var buffer = new byte [10];
var buffer_big = new byte [25];
stream.Write (buffer, 0, 10);
stream.Write (buffer, 0, 10);
stream.Seek (-15, SeekOrigin.Current);
Assert.AreEqual (5, stream.Position);
stream.Write (buffer_big, 0, 25);
long pos = stream.Position;
Assert.AreEqual (30, pos);
}
示例6: Write_SeekedBackInLastSegment_SetsPosition
public void Write_SeekedBackInLastSegment_SetsPosition()
{
var stream = new HttpResponseStream ();
var buffer = new byte [10];
stream.Write (buffer, 0, 10);
stream.Write (buffer, 0, 10);
stream.Seek (-5, SeekOrigin.Current);
stream.Write (buffer, 0, 10);
long pos = stream.Position;
Assert.AreEqual (25, pos);
}
示例7: Write_InFirstBufferOfTwoBufferStream_SetsCorrectLength
public void Write_InFirstBufferOfTwoBufferStream_SetsCorrectLength()
{
var stream = new HttpResponseStream ();
var write_buffer = new byte [5];
stream.Write (write_buffer, 0, 5);
stream.Write (write_buffer, 0, 5);
stream.Seek (-6, SeekOrigin.End);
stream.Write (write_buffer, 0, 5);
var length = stream.Length;
Assert.AreEqual (10, length);
}
示例8: Write_AcrossEntireMiddleBufferOfThreeBufferStream_SetsCorrectLength
public void Write_AcrossEntireMiddleBufferOfThreeBufferStream_SetsCorrectLength()
{
var stream = new HttpResponseStream ();
var write_buffer = new byte [5];
var write_buffer2 = new byte [6];
stream.Write (write_buffer, 0, 5);
stream.Write (write_buffer, 0, 5);
stream.Write (write_buffer, 0, 5);
stream.Seek (2, SeekOrigin.Begin);
stream.Write (write_buffer2, 0, 6);
var length = stream.Length;
Assert.AreEqual (15, length);
}
示例9: Seek_SeekToBeginningOfEmptyStream_SetsPosition
public void Seek_SeekToBeginningOfEmptyStream_SetsPosition()
{
var stream = new HttpResponseStream ();
stream.Seek (0, SeekOrigin.Begin);
var position = stream.Position;
Assert.AreEqual (0, position);
}
示例10: Seek_FromEnd_SetsPosition
public void Seek_FromEnd_SetsPosition()
{
var stream = new HttpResponseStream ();
var buffer = new byte [10];
stream.Write (buffer, 0, 10);
stream.Seek (-3, SeekOrigin.End);
long pos = stream.Position;
Assert.AreEqual (7, pos);
}
示例11: Seek_FromEndMultipleBuffersAcrossBoundries_SetsPosition
public void Seek_FromEndMultipleBuffersAcrossBoundries_SetsPosition()
{
var stream = new HttpResponseStream ();
var buffer = new byte [10];
stream.Write (buffer, 0, 10);
stream.Write (buffer, 0, 10);
stream.Write (buffer, 0, 10);
stream.Seek (-25, SeekOrigin.End);
long pos = stream.Position;
Assert.AreEqual (5, pos);
}
示例12: Seek_FromCurrentBackwards_SetsPosition
public void Seek_FromCurrentBackwards_SetsPosition()
{
var stream = new HttpResponseStream ();
var buffer = new byte [10];
stream.Write (buffer, 0, 10);
stream.Write (buffer, 0, 10);
stream.Seek (-5, SeekOrigin.Current);
long pos = stream.Position;
Assert.AreEqual (15, pos);
}
示例13: Seek_FromBeginningMultipleSegments_SetsPosition
public void Seek_FromBeginningMultipleSegments_SetsPosition()
{
var stream = new HttpResponseStream ();
var buffer = new byte [10];
stream.Write (buffer, 0, 10);
stream.Write (buffer, 0, 10);
stream.Write (buffer, 0, 10);
stream.Seek (25, SeekOrigin.Begin);
long pos = stream.Position;
Assert.AreEqual (25, pos);
}
示例14: SeekOrigin_PositivePastEnd_Throws
public void SeekOrigin_PositivePastEnd_Throws()
{
var stream = new HttpResponseStream ();
var buffer = new byte [10];
stream.Write (buffer, 0, 10);
Should.Throw<ArgumentException> (() => stream.Seek (11, SeekOrigin.Begin));
}
示例15: Read_SingleBuffer_CorrectData
public void Read_SingleBuffer_CorrectData()
{
var stream = new HttpResponseStream ();
var write_buffer = new byte [3];
var read_buffer = new byte [1];
write_buffer [2] = 0xFA;
stream.Write (write_buffer, 0, 3);
stream.Seek (-1, SeekOrigin.End);
stream.Read (read_buffer, 0, 1);
byte read_byte = read_buffer [0];
Assert.AreEqual (0xFA, read_byte);
}