WriteBytes() public method

public WriteBytes ( byte value ) : void
value byte
return void
コード例 #1
0
	    public void TestWriteOnlyBody() 
		{
	        ActiveMQBytesMessage message = new ActiveMQBytesMessage();
	        message.ClearBody();
	        
			try
			{
	            message.WriteBoolean(true);
	            message.WriteByte((byte) 1);
	            message.WriteBytes(new byte[1]);
	            message.WriteBytes(new byte[3], 0, 2);
	            message.WriteChar('a');
	            message.WriteDouble(1.5);
	            message.WriteSingle((float) 1.5);
	            message.WriteInt32(1);
	            message.WriteInt64(1);
	            message.WriteObject("stringobj");
	            message.WriteInt16((short) 1);
	            message.WriteString("utfstring");
	        }
			catch(MessageNotWriteableException)
			{
	            Assert.Fail("Should be writeable");
	        }
			
	        try
			{
	            message.ReadBoolean();
	            Assert.Fail("Should have thrown exception");
	        }
			catch(MessageNotReadableException)
			{
	        }
	        
			try
			{
	            message.ReadByte();
	            Assert.Fail("Should have thrown exception");
	        }
			catch(MessageNotReadableException)
			{
	        }
	        
			try
			{
	            message.ReadBytes(new byte[1]);
	            Assert.Fail("Should have thrown exception");
	        }
			catch(MessageNotReadableException)
			{
	        }
	        
			try
			{
	            message.ReadBytes(new byte[2], 2);
	            Assert.Fail("Should have thrown exception");
	        }
			catch(MessageNotReadableException)
			{
	        }
	        
			try
			{
	            message.ReadChar();
	            Assert.Fail("Should have thrown exception");
	        }
			catch(MessageNotReadableException)
			{
	        }
	        
			try
			{
	            message.ReadDouble();
	            Assert.Fail("Should have thrown exception");
	        }
			catch(MessageNotReadableException)
			{
	        }
	        
			try 
			{
	            message.ReadSingle();
	            Assert.Fail("Should have thrown exception");
	        }
			catch(MessageNotReadableException)
			{
	        }
	        
			try
			{
	            message.ReadInt32();
	            Assert.Fail("Should have thrown exception");
	        }
			catch(MessageNotReadableException)
			{
	        }
	        
			try
			{
	            message.ReadInt64();
	            Assert.Fail("Should have thrown exception");
	        }
			catch(MessageNotReadableException)
			{
	        }
	        
			try
			{
	            message.ReadString();
	            Assert.Fail("Should have thrown exception");
	        }
			catch(MessageNotReadableException)
			{
	        }
	        
			try
			{
	            message.ReadInt16();
	            Assert.Fail("Should have thrown exception");
	        }
			catch(MessageNotReadableException)
			{
	        }
	        
			try 
			{
	            message.ReadString();
	            Assert.Fail("Should have thrown exception");
	        } 
			catch(MessageNotReadableException) 
			{
	        }
	    }		
コード例 #2
0
	    public void TestReadBytesbyteArray() 
		{
	        ActiveMQBytesMessage msg = new ActiveMQBytesMessage();
            byte[] data = new byte[50];
            for(int i = 0; i < data.Length; i++) 
			{
                data[i] = (byte) i;
            }
            msg.WriteBytes(data);
            msg.Reset();
            byte[] test = new byte[data.Length];
            msg.ReadBytes(test);
            for(int i = 0; i < test.Length; i++) 
			{
                Assert.IsTrue(test[i] == i);
            }
	    }