Ejemplo n.º 1
0
        public static void UmaReadWriteGenericStringStruct_ThrowsArgumentException()
        {
            const int capacity = 100;
            UmaTestStruct_Generic <string> inStruct = new UmaTestStruct_Generic <string>()
            {
                ofT = "Cats!"
            };

            using (var buffer = new TestSafeBuffer(capacity))
                using (var uma = new UnmanagedMemoryAccessor(buffer, 0, capacity, FileAccess.ReadWrite))
                {
                    AssertExtensions.Throws <ArgumentException>(null, "type", () => uma.Write <UmaTestStruct_Generic <string> >(0, ref inStruct));
                    AssertExtensions.Throws <ArgumentException>(null, "type", () => uma.Read <UmaTestStruct_Generic <string> >(0, out inStruct));
                }
        }
Ejemplo n.º 2
0
        public static void UmaReadWriteGenericIntStruct_Valid()
        {
            const int capacity = 100;
            UmaTestStruct_Generic <int> inStruct = new UmaTestStruct_Generic <int> ()
            {
                ofT = 158
            };
            UmaTestStruct_Generic <int> outStruct;

            using (var buffer = new TestSafeBuffer(capacity))
                using (var uma = new UnmanagedMemoryAccessor(buffer, 0, capacity, FileAccess.ReadWrite))
                {
                    uma.Write <UmaTestStruct_Generic <int> >(0, ref inStruct);
                    uma.Read <UmaTestStruct_Generic <int> >(0, out outStruct);
                    Assert.Equal(inStruct.ofT, outStruct.ofT);
                }
        }
Ejemplo n.º 3
0
        public static void UmaReadWriteGenericStringStructArray_ThrowsArgumentException()
        {
            const int capacity = 100;

            UmaTestStruct_Generic <string>[] structArr = new UmaTestStruct_Generic <string>[1] {
                new UmaTestStruct_Generic <string>()
                {
                    ofT = "Cats!"
                }
            };
            using (var buffer = new TestSafeBuffer(capacity))
                using (var uma = new UnmanagedMemoryAccessor(buffer, 0, capacity, FileAccess.ReadWrite))
                {
                    AssertExtensions.Throws <ArgumentException>("type", () => uma.WriteArray <UmaTestStruct_Generic <string> >(0, structArr, 0, 1));
                    AssertExtensions.Throws <ArgumentException>("type", () => uma.ReadArray <UmaTestStruct_Generic <string> >(0, structArr, 0, 1));
                }
        }
Ejemplo n.º 4
0
        public static void UmaReadWriteStructArrayGenericIntStruct_Valid()
        {
            const int capacity = 100;

            UmaTestStruct_Generic <int>[] inStructArr = new UmaTestStruct_Generic <int>[1] {
                new UmaTestStruct_Generic <int>()
                {
                    ofT = 190
                }
            };
            UmaTestStruct_Generic <int>[] outStructArr = new UmaTestStruct_Generic <int> [1];
            using (var buffer = new TestSafeBuffer(capacity))
                using (var uma = new UnmanagedMemoryAccessor(buffer, 0, capacity, FileAccess.ReadWrite))
                {
                    uma.WriteArray <UmaTestStruct_Generic <int> >(0, inStructArr, 0, 1);
                    Assert.Equal(1, uma.ReadArray <UmaTestStruct_Generic <int> >(0, outStructArr, 0, 1));
                    Assert.Equal(inStructArr[0].ofT, outStructArr[0].ofT);
                }
        }
Ejemplo n.º 5
0
 public static void UmaReadWriteGenericStringStruct_ThrowsArgumentException()
 {
     const int capacity = 100;
     UmaTestStruct_Generic<string> inStruct = new UmaTestStruct_Generic<string>() { ofT = "Cats!" };
     using (var buffer = new TestSafeBuffer(capacity))
     using (var uma = new UnmanagedMemoryAccessor(buffer, 0, capacity, FileAccess.ReadWrite))
     {
         Assert.Throws<ArgumentException>("type", () => uma.Write<UmaTestStruct_Generic<string>>(0, ref inStruct));
         Assert.Throws<ArgumentException>("type", () => uma.Read<UmaTestStruct_Generic<string>>(0, out inStruct));
     }
 }
Ejemplo n.º 6
0
 public static void UmaReadWriteGenericIntStruct_Valid()
 {
     const int capacity = 100;
     UmaTestStruct_Generic<int> inStruct = new UmaTestStruct_Generic<int> () { ofT = 158 };
     UmaTestStruct_Generic<int> outStruct;
     using (var buffer = new TestSafeBuffer(capacity))
     using (var uma = new UnmanagedMemoryAccessor(buffer, 0, capacity, FileAccess.ReadWrite))
     {
         uma.Write<UmaTestStruct_Generic<int>>(0, ref inStruct);
         uma.Read<UmaTestStruct_Generic<int>>(0, out outStruct);
         Assert.Equal(inStruct.ofT, outStruct.ofT);
     }
 }
Ejemplo n.º 7
0
 public static void UmaReadWriteStructArrayGenericIntStruct_Valid()
 {
     const int capacity = 100;
     UmaTestStruct_Generic<int>[] inStructArr = new UmaTestStruct_Generic<int>[1] { new UmaTestStruct_Generic<int>() { ofT = 190 } };
     UmaTestStruct_Generic<int>[] outStructArr = new UmaTestStruct_Generic<int>[1];
     using (var buffer = new TestSafeBuffer(capacity))
     using (var uma = new UnmanagedMemoryAccessor(buffer, 0, capacity, FileAccess.ReadWrite))
     {
         uma.WriteArray<UmaTestStruct_Generic<int>>(0, inStructArr, 0, 1);
         Assert.Equal(1, uma.ReadArray<UmaTestStruct_Generic<int>>(0, outStructArr, 0, 1));
         Assert.Equal(inStructArr[0].ofT, outStructArr[0].ofT);
     }
 }