예제 #1
0
 public byte[] Should_the_origin_memory_contain_the_correct_data_when_using_the_WRITE_method(int startOffset, int value)
 {
     using (var managedMemory = new ManagedMemory(10)) {
         using (var subset = new MemorySubset(managedMemory, 2, 4, false)) {
             subset.Write(startOffset, (byte)value);
             return(managedMemory.ToArray());
         }
     }
 }
 public void Should_the_origin_memory_contain_the_correct_data_when_using_the_WRITE_method(int startOffset, int value, byte[] expectedResult)
 {
     using (var managedMemory = new ManagedMemory(10)) {
         using (var subset = new MemorySubset(managedMemory, 2, 4, false)) {
             if (expectedResult == null)
             {
                 Assert.Throws <ArgumentOutOfRangeException>(delegate { subset.Write(startOffset, (byte)value); });
             }
             else
             {
                 subset.Write(startOffset, (byte)value);
                 var memo = managedMemory.ToArray();
                 for (var i = 0; i < expectedResult.Length; i++)
                 {
                     Assert.AreEqual(expectedResult[i], memo[i]);
                 }
             }
         }
     }
 }
예제 #3
0
 public void Should_the_origin_memory_contain_the_correct_data_when_using_the_WRITE_method_exception(int startOffset, int value)
 {
     Assert.Throws <ArgumentOutOfRangeException>(() =>
     {
         using (var managedMemory = new ManagedMemory(10))
         {
             using (var subset = new MemorySubset(managedMemory, 2, 4, false))
             {
                 subset.Write(startOffset, (byte)value);
             }
         }
     });
 }