WriteByte() private method

private WriteByte ( byte value ) : void
value byte
return void
Example #1
0
 public override void WriteByte(byte value)
 {
     _unmanagedStream.WriteByte(value);
 }
		public void WriteByte_Stream_ReadOnly ()
		{
			UnmanagedMemoryStream ums = new 
				UnmanagedMemoryStream(mem_byteptr, length);
			try {
				ums.WriteByte (testStreamData [0]);
				Assert.Fail ("#1");
			} catch (NotSupportedException ex) {
				// Stream does not support writing
				Assert.AreEqual (typeof (NotSupportedException), ex.GetType (), "#2");
				Assert.IsNull (ex.InnerException, "#3");
				Assert.IsNotNull (ex.Message, "#4");
			}
			ums.Close ();
		}
		public void WriteByte_Capacity_Exceeded ()
		{
			UnmanagedMemoryStream ums = new 
				UnmanagedMemoryStream(mem_byteptr, 1, 2, FileAccess.ReadWrite);
			ums.WriteByte (0x44);
			ums.WriteByte (0x45);
			try {
				ums.WriteByte (0x46);
				Assert.Fail ("#1");
			} catch (NotSupportedException ex) {
				// Unable to expand length of this stream beyond its capacity
				Assert.AreEqual (typeof (NotSupportedException), ex.GetType (), "#2");
				Assert.IsNull (ex.InnerException, "#3");
				Assert.IsNotNull (ex.Message, "#4");
			}
			ums.Close();
		}
		public void WriteByte_Stream_Closed ()
		{
			UnmanagedMemoryStream ums = new UnmanagedMemoryStream(mem_byteptr,
				length, length, FileAccess.Write);
			ums.Close();
			ums.WriteByte(0x12);
		}
		public void WriteByte ()
		{
			UnmanagedMemoryStream ums = new 
				UnmanagedMemoryStream(mem_byteptr, 3, 5, FileAccess.ReadWrite);
			ums.WriteByte (testStreamData [0]);
			Assert.AreEqual (5, ums.Capacity, "#A1");
			Assert.AreEqual (1, ums.Position, "#A2");
			Assert.AreEqual (3, ums.Length, "#A3");
			ums.WriteByte (testStreamData [1]);
			Assert.AreEqual (5, ums.Capacity, "#B1");
			Assert.AreEqual (2, ums.Position, "#B2");
			Assert.AreEqual (3, ums.Length, "#B3");
			ums.WriteByte (testStreamData [2]);
			Assert.AreEqual (5, ums.Capacity, "#C1");
			Assert.AreEqual (3, ums.Position, "#C2");
			Assert.AreEqual (3, ums.Length, "#C3");
			ums.WriteByte (testStreamData [3]);
			Assert.AreEqual (5, ums.Capacity, "#D1");
			Assert.AreEqual (4, ums.Position, "#D2");
			Assert.AreEqual (4, ums.Length, "#D3");
			ums.WriteByte (testStreamData [4]);
			Assert.AreEqual (5, ums.Capacity, "#E1");
			Assert.AreEqual (5, ums.Position, "#E2");
			Assert.AreEqual (5, ums.Length, "#E3");
			ums.Seek (0, SeekOrigin.Begin);
			Assert.AreEqual (testStreamData [0], ums.ReadByte (), "#F1");
			Assert.AreEqual (testStreamData [1], ums.ReadByte (), "#F2");
			Assert.AreEqual (testStreamData [2], ums.ReadByte (), "#F3");
			Assert.AreEqual (testStreamData [3], ums.ReadByte (), "#F4");
			Assert.AreEqual (testStreamData [4], ums.ReadByte (), "#F5");
			ums.Close ();
		}
		public void PositionPointer_Set ()
		{
			byte [] n = new byte [8];
			n [4] = 65;
			fixed (byte* p = n) {
				UnmanagedMemoryStream m = new UnmanagedMemoryStream (p, 8, 8, FileAccess.ReadWrite);
				m.PositionPointer = p + 4;
				Assert.AreEqual (65, m.ReadByte (), "read");
				m.WriteByte (42);
			}
			Assert.AreEqual (42, n [5], "write");
		}