本文整理汇总了C#中HttpResponseStream.Write方法的典型用法代码示例。如果您正苦于以下问题:C# HttpResponseStream.Write方法的具体用法?C# HttpResponseStream.Write怎么用?C# HttpResponseStream.Write使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HttpResponseStream
的用法示例。
在下文中一共展示了HttpResponseStream.Write方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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);
}
示例2: 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);
}
示例3: 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);
}
示例4: 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);
}
示例5: Insert_BeginningOfStream_SetsCorrectPosition
public void Insert_BeginningOfStream_SetsCorrectPosition()
{
var stream = new HttpResponseStream ();
var write_buffer = new byte [10];
stream.Write (write_buffer, 0, 10);
stream.Position = 0;
stream.Insert (write_buffer, 0, 5);
var position = stream.Position;
Assert.AreEqual (5, position);
}
示例6: Insert_BeginningOfStream_SetsCorrectLength
public void Insert_BeginningOfStream_SetsCorrectLength()
{
var stream = new HttpResponseStream ();
var write_buffer = new byte [10];
stream.Write (write_buffer, 0, 10);
stream.Position = 0;
stream.Insert (write_buffer, 0, 10);
var length = stream.Length;
Assert.AreEqual (20, length);
}
示例7: Insert_BeginningOfStream_SetsCorrectData
public void Insert_BeginningOfStream_SetsCorrectData()
{
var stream = new HttpResponseStream ();
var write_buffer = new byte [10];
var write_buffer2 = new byte [10];
stream.Write (write_buffer, 0, 10);
stream.Position = 0;
write_buffer2 [2] = 0xFA;
stream.Insert (write_buffer2, 0, 10);
stream.Position = 2;
var data = stream.ReadByte ();
Assert.AreEqual (0xFA, data);
}
示例8: Write_TruncatedSegment_SetsLength
public void Write_TruncatedSegment_SetsLength()
{
var stream = new HttpResponseStream ();
var buffer = new byte [10];
stream.Write (buffer, 0, 5);
long len = stream.Length;
Assert.AreEqual (5, len);
}
示例9: Write_ShorterThanBufferInSingleBuffer_SetsCorrectLength
public void Write_ShorterThanBufferInSingleBuffer_SetsCorrectLength()
{
var stream = new HttpResponseStream ();
var write_buffer = new byte [5];
stream.Write (write_buffer, 0, 5);
stream.Position = 2;
stream.Write (write_buffer, 0, 2);
var length = stream.Length;
Assert.AreEqual (5, length);
}
示例10: 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);
}
示例11: 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);
}
示例12: 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);
}
示例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: 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);
}
示例15: SetLength_LessThanSingleBuffer_Truncates
public void SetLength_LessThanSingleBuffer_Truncates()
{
var stream = new HttpResponseStream ();
var buffer = new byte [10];
stream.Write (buffer, 0, 10);
stream.SetLength (5);
long length = stream.Length;
Assert.AreEqual (5, length);
}