示例#1
0
        public void StructureToPtr_AutoLayout_ThrowsArgumentException()
        {
            var someTs_Auto = new SomeTestStruct_Auto();

            AssertExtensions.Throws <ArgumentException>("structure", () => Marshal.StructureToPtr((object)someTs_Auto, (IntPtr)1, fDeleteOld: true));
            AssertExtensions.Throws <ArgumentException>("structure", () => Marshal.StructureToPtr(someTs_Auto, (IntPtr)1, fDeleteOld: true));
        }
示例#2
0
        public void DestroyStructure_Negative()
        {
            IntPtr ip;

            ip = IntPtr.Zero;
            AssertExtensions.Throws <ArgumentNullException>("ptr", () => Marshal.DestroyStructure <SomeTestStruct>(ip));

            ip = new IntPtr(123);
            AssertExtensions.Throws <ArgumentNullException>("structureType", () => Marshal.DestroyStructure(ip, null));

            SomeTestStruct_Auto someTs_Auto = new SomeTestStruct_Auto();

            Assert.Throws <ArgumentException>(() => Marshal.DestroyStructure(ip, someTs_Auto.GetType()));
        }
示例#3
0
 public void AutoLayoutStructureTest()
 {
     var someTs_Auto      = new SomeTestStruct_Auto();
     ArgumentException ex = AssertExtensions.Throws <ArgumentException>("structure", () => Marshal.StructureToPtr(someTs_Auto, new IntPtr(123), true));
 }