public void VerifyCheckDataSizeThrowsExceptionWhenCbDataIsNonZeroAndPvDataIsNull()
 {
     var setcolumn = new JET_SETCOLUMN
     {
         cbData = 1,
     };
     setcolumn.CheckDataSize();
 }
 public void VerifyValidateThrowsExceptionWhenIbLongValueIsNegative()
 {
     var setcolumn = new JET_SETCOLUMN
     {
         ibLongValue = -1,
     };
     setcolumn.Validate();
 }
 public void VerifyValidateThrowsExceptionWhenPvDataIsNull()
 {
     var setcolumn = new JET_SETCOLUMN
     {
         cbData = 1,
     };
     setcolumn.Validate();
 }
 public void VerifyValidateThrowsExceptionWhenItagSequenceIsNegative()
 {
     var setcolumn = new JET_SETCOLUMN
     {
         itagSequence = -1,
     };
     setcolumn.Validate();
 }
 public void VerifyCheckDataSizeThrowsExceptionWhenIbDataCbDataIsTooLong()
 {
     var setcolumn = new JET_SETCOLUMN
     {
         ibData = 4,
         pvData = new byte[4],
     };
     setcolumn.CheckDataSize();
 }
 public void VerifyCheckDataSizeThrowsExceptionWhenCbDataIsNegative()
 {
     var setcolumn = new JET_SETCOLUMN
     {
         cbData = -1,
         pvData = new byte[1],
     };
     setcolumn.CheckDataSize();
 }
Example #7
0
 public void VerifyCheckThrowsExceptionWhenCbDataIsTooLong()
 {
     var setcolumn = new JET_SETCOLUMN
     {
         cbData = 100,
         pvData = new byte[9],
     };
     setcolumn.CheckDataSize();
 }
 public void VerifyValidateThrowsExceptionWhenCbDataIsTooLong()
 {
     var setcolumn = new JET_SETCOLUMN
     {
         cbData = 100,
         pvData = new byte[9],
     };
     setcolumn.Validate();
 }
 public void Setup()
 {
     this.managed = new JET_SETCOLUMN
     {
         cbData = 1,
         columnid = new JET_COLUMNID { Value = 2 },
         grbit = SetColumnGrbit.AppendLV,
         ibLongValue = 3,
         itagSequence = 4,
     };
     this.native = this.managed.GetNativeSetcolumn();
 }
 public void VerifyCheckDataSizeThrowsExceptionWhenItagSequenceIsNegative()
 {
     var setcolumn = new JET_SETCOLUMN
     {
         itagSequence = -1,
     };
     setcolumn.CheckDataSize();
 }
 public void VerifyCheckDataSizeThrowsExceptionWhenIbLongValueIsNegative()
 {
     var setcolumn = new JET_SETCOLUMN
     {
         ibLongValue = -1,
     };
     setcolumn.CheckDataSize();
 }
Example #12
0
        public static JET_wrn JetSetColumns(JET_SESID sesid, JET_TABLEID tableid, JET_SETCOLUMN[] setcolumns, int numColumns)
        {
            if (null == setcolumns)
            {
                throw new ArgumentNullException("setcolumns");
            }

            if (numColumns < 0 || numColumns > setcolumns.Length)
            {
                throw new ArgumentOutOfRangeException("numColumns", numColumns, "cannot be negative or greater than setcolumns.Length");
            }

            using (var gchandles = new GCHandleCollection())
            {
                unsafe
                {
                    NATIVE_SETCOLUMN* nativeSetColumns = stackalloc NATIVE_SETCOLUMN[numColumns];

                    // For performance, copy small amounts of data into a local buffer instead
                    // of pinning the data.
                    const int BufferSize = 128;
                    byte* buffer = stackalloc byte[BufferSize];
                    int bufferRemaining = BufferSize;

                    for (int i = 0; i < numColumns; ++i)
                    {
                        setcolumns[i].CheckDataSize();
                        nativeSetColumns[i] = setcolumns[i].GetNativeSetcolumn();
                        if (null == setcolumns[i].pvData)
                        {
                            nativeSetColumns[i].pvData = IntPtr.Zero;
                        }
                        else if (bufferRemaining >= setcolumns[i].cbData)
                        {
                            nativeSetColumns[i].pvData = new IntPtr(buffer);
                            Marshal.Copy(setcolumns[i].pvData, setcolumns[i].ibData, nativeSetColumns[i].pvData, setcolumns[i].cbData);
                            buffer += setcolumns[i].cbData;
                            bufferRemaining -= setcolumns[i].cbData;
                            Debug.Assert(bufferRemaining >= 0, "Buffer remaining is negative");
                        }
                        else
                        {
                            byte* pinnedBuffer = (byte*)gchandles.Add(setcolumns[i].pvData).ToPointer();
                            nativeSetColumns[i].pvData = new IntPtr(pinnedBuffer + setcolumns[i].ibData);
                        }
                    }

                    int err = Impl.JetSetColumns(sesid, tableid, nativeSetColumns, numColumns);
                    for (int i = 0; i < numColumns; ++i)
                    {
                        setcolumns[i].err = (JET_wrn)nativeSetColumns[i].err;
                    }

                    return Api.Check(err);
                }
            }
        }
Example #13
0
 public void JetSetColumnToString()
 {
     var value = new JET_SETCOLUMN { columnid = new JET_COLUMNID { Value = 0x1234F } };
     Assert.AreEqual("JET_SETCOLUMN(0x1234f,<null>,ibLongValue=0,itagSequence=0)", value.ToString());
 }