Exemple #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));
        }
        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()));
        }
 public void AutoLayoutStructureTest()
 {
     var someTs_Auto      = new SomeTestStruct_Auto();
     ArgumentException ex = AssertExtensions.Throws <ArgumentException>("structure", () => Marshal.StructureToPtr(someTs_Auto, new IntPtr(123), true));
 }