Exemple #1
0
        public void an_empty_pool_should_return_an_empty_array()
        {
            BufferPool pool = new BufferPool(1, BufferManager);

            byte[] arr = pool.ToByteArray();
            Assert.AreEqual(0, arr.Length);
        }
 /// <summary>
 /// Converts the message to a byte array
 /// </summary>
 /// <param name="message">The message.</param>
 /// <returns></returns>
 public virtual byte[] ToArray(T message)
 {
     using (BufferPool pool = ToBufferPool(message))
     {
         return(pool.ToByteArray());
     }
 }
Exemple #3
0
        public void the_byte_array_should_be_the_same_length_as_the_pool_with_data()
        {
            BufferPool pool = new BufferPool(5, BufferManager);

            for (int i = 0; i < 500; i++)
            {
                pool[i] = 12;
            }
            Assert.AreEqual(500, pool.ToByteArray().Length);
        }
Exemple #4
0
        public void the_byte_array_should_have_the_same_data_as_the_pool_with_a_single_buffer()
        {
            BufferPool pool = new BufferPool(5, BufferManager);

            for (int i = 0; i < 5; i++)
            {
                pool[i] = (byte)(i % 255);
            }
            byte[] data = pool.ToByteArray();
            for (int i = 0; i < 5; i++)
            {
                Assert.AreEqual((byte)(i % 255), data[i]);
            }
        }
 public void the_byte_array_should_be_the_same_length_as_the_pool_with_data()
 {
     BufferPool pool = new BufferPool(5, BufferManager);
     for (int i = 0; i < 500; i++)
     {
         pool[i] = 12;
     }
     Assert.AreEqual(500, pool.ToByteArray().Length);
 }
 public void an_empty_pool_should_return_an_empty_array()
 {
     BufferPool pool = new BufferPool(1, BufferManager);
     byte[] arr = pool.ToByteArray();
     Assert.AreEqual(0, arr.Length);
 }
 public void the_byte_array_should_have_the_same_data_as_the_pool_with_a_single_buffer()
 {
     BufferPool pool = new BufferPool(5, BufferManager);
     for (int i = 0; i < 5; i++)
     {
         pool[i] = (byte)(i % 255);
     }
     byte[] data = pool.ToByteArray();
     for (int i = 0; i < 5; i++)
     {
         Assert.AreEqual((byte)(i % 255), data[i]);
     }
 }
Exemple #8
0
 public byte[] From(BufferPool bufferPool)
 {
     return(bufferPool.ToByteArray());
 }
Exemple #9
0
 public void converting_to_a_byte_array_throws_objectdisposedexception()
 {
     Assert.Throws <ObjectDisposedException>(() => { m_DisposedPool.ToByteArray(); });
 }
Exemple #10
0
 public void converting_to_a_byte_array_throws_objectdisposedexception()
 {
     m_DisposedPool.ToByteArray();
 }