/SharedLibs/Sources/managedesent-61618/EsentInteropTests/ParameterCheckingTests.cs
https://github.com/dangerwheeler/ravendb · C# · 1201 lines · 776 code · 103 blank · 322 comment · 4 complexity · dd14ad49c728521a2b5047d5e3e7cf8a MD5 · raw file
- //-----------------------------------------------------------------------
- // <copyright file="ParameterCheckingTests.cs" company="Microsoft Corporation">
- // Copyright (c) Microsoft Corporation.
- // </copyright>
- //-----------------------------------------------------------------------
-
- namespace InteropApiTests
- {
- using System;
- using System.Linq;
- using Microsoft.Isam.Esent.Interop;
- using Microsoft.Isam.Esent.Interop.Server2003;
- using Microsoft.Isam.Esent.Interop.Vista;
- using Microsoft.Isam.Esent.Interop.Windows7;
- using Microsoft.VisualStudio.TestTools.UnitTesting;
-
- /// <summary>
- /// Test for API parameter validation code
- /// </summary>
- [TestClass]
- public class ParameterCheckingTests
- {
- /// <summary>
- /// The instance used by the test.
- /// </summary>
- private readonly JET_INSTANCE instance = JET_INSTANCE.Nil;
-
- /// <summary>
- /// The session used by the test.
- /// </summary>
- private readonly JET_SESID sesid = JET_SESID.Nil;
-
- /// <summary>
- /// The table used by the test.
- /// </summary>
- private readonly JET_TABLEID tableid = JET_TABLEID.Nil;
-
- /// <summary>
- /// The columnid used by the test.
- /// </summary>
- private readonly JET_COLUMNID columnid = JET_COLUMNID.Nil;
-
- /// <summary>
- /// Identifies the database used by the test.
- /// </summary>
- private readonly JET_DBID dbid = JET_DBID.Nil;
-
- #region Setup/Teardown
- /// <summary>
- /// Verifies no instances are leaked.
- /// </summary>
- [TestCleanup]
- public void Teardown()
- {
- SetupHelper.CheckProcessForInstanceLeaks();
- }
-
- #endregion
-
- #region System Parameter tests
-
- /// <summary>
- /// Check that an exception is thrown when JetGetSystemParameter gets a
- /// negative max param value.
- /// </summary>
- [TestMethod]
- [Priority(0)]
- [ExpectedException(typeof(ArgumentOutOfRangeException))]
- [Description("Check that an exception is thrown when JetGetSystemParameter gets a negative max param value")]
- public void JetGetSystemParameterThrowsExceptionWhenMaxParamIsNegative()
- {
- int ignored = 0;
- string value;
- Api.JetGetSystemParameter(this.instance, this.sesid, JET_param.SystemPath, ref ignored, out value, -1);
- }
-
- /// <summary>
- /// Check that an exception is thrown when JetGetSystemParameter gets a
- /// too large max param value.
- /// </summary>
- [TestMethod]
- [Priority(0)]
- [ExpectedException(typeof(OverflowException))]
- [Description("Check that an exception is thrown when JetGetSystemParameter gets a too large max param value")]
- public void JetGetSystemParameterThrowsExceptionWhenMaxParamIsTooBig()
- {
- // This test only fails with the Unicode API (the overflow happens when we try
- // to multiply maxParam by sizeof(char))
- if (!EsentVersion.SupportsUnicodePaths)
- {
- throw new OverflowException();
- }
-
- int ignored = 0;
- string value;
- Api.JetGetSystemParameter(this.instance, this.sesid, JET_param.SystemPath, ref ignored, out value, Int32.MaxValue);
- }
-
- #endregion
-
- #region Database API
-
- /// <summary>
- /// Check that an exception is thrown when JetCreateDatabase gets a
- /// null database name.
- /// </summary>
- [TestMethod]
- [Priority(0)]
- [ExpectedException(typeof(ArgumentNullException))]
- [Description("Check that an exception is thrown when JetCreateDatabase gets a null database name")]
- public void JetCreateDatabaseThrowsExceptionWhenDatabaseNameIsNull()
- {
- JET_DBID dbid;
- Api.JetCreateDatabase(this.sesid, null, null, out dbid, CreateDatabaseGrbit.None);
- }
-
- /// <summary>
- /// Check that an exception is thrown when JetCreateDatabase2 gets a
- /// null database name.
- /// </summary>
- [TestMethod]
- [Priority(0)]
- [ExpectedException(typeof(ArgumentNullException))]
- [Description("Check that an exception is thrown when JetCreateDatabase2 gets a null database name")]
- public void JetCreateDatabase2ThrowsExceptionWhenDatabaseNameIsNull()
- {
- JET_DBID dbid;
- Api.JetCreateDatabase2(this.sesid, null, 0, out dbid, CreateDatabaseGrbit.None);
- }
-
- /// <summary>
- /// Check that an exception is thrown when JetCreateDatabase2 gets a
- /// null database name.
- /// </summary>
- [TestMethod]
- [Priority(0)]
- [ExpectedException(typeof(ArgumentOutOfRangeException))]
- [Description("Check that an exception is thrown when JetCreateDatabase2 gets a negative page count")]
- public void JetCreateDatabase2ThrowsExceptionWhenPageCountIsNegative()
- {
- JET_DBID dbid;
- Api.JetCreateDatabase2(this.sesid, "foo.db", -2, out dbid, CreateDatabaseGrbit.None);
- }
-
- /// <summary>
- /// Check that an exception is thrown when JetAttachDatabase gets a
- /// null database name.
- /// </summary>
- [TestMethod]
- [Priority(0)]
- [ExpectedException(typeof(ArgumentNullException))]
- [Description("Check that an exception is thrown when JetAttachDatabase gets a null database name")]
- public void JetAttachDatabaseThrowsExceptionWhenDatabaseNameIsNull()
- {
- Api.JetAttachDatabase(this.sesid, null, AttachDatabaseGrbit.None);
- }
-
- /// <summary>
- /// Check that an exception is thrown when JetAttachDatabase2 gets a
- /// null database name.
- /// </summary>
- [TestMethod]
- [Priority(0)]
- [ExpectedException(typeof(ArgumentNullException))]
- [Description("Check that an exception is thrown when JetAttachDatabase2 gets null database name")]
- public void JetAttachDatabase2ThrowsExceptionWhenDatabaseNameIsNull()
- {
- Api.JetAttachDatabase2(this.sesid, null, 0, AttachDatabaseGrbit.None);
- }
-
- /// <summary>
- /// Check that an exception is thrown when JetAttachDatabase2 gets a
- /// negative max page count.
- /// </summary>
- [TestMethod]
- [Priority(0)]
- [ExpectedException(typeof(ArgumentOutOfRangeException))]
- [Description("Check that an exception is thrown when JetAttachDatabase2 gets negative max page count")]
- public void JetAttachDatabase2ThrowsExceptionWhenMaxPagesIsNegative()
- {
- Api.JetAttachDatabase2(this.sesid, "foo.db", -1, AttachDatabaseGrbit.None);
- }
-
- /// <summary>
- /// Check that an exception is thrown when JetOpenDatabase gets a
- /// null database name.
- /// </summary>
- [TestMethod]
- [Priority(0)]
- [ExpectedException(typeof(ArgumentNullException))]
- [Description("Check that an exception is thrown when JetOpenDatabase gets null database name")]
- public void JetOpenDatabaseThrowsExceptionWhenDatabaseNameIsNull()
- {
- JET_DBID dbid;
- Api.JetOpenDatabase(this.sesid, null, null, out dbid, OpenDatabaseGrbit.None);
- }
-
- /// <summary>
- /// Check that an exception is thrown when JetGrowDatabase gets
- /// a negative page count.
- /// </summary>
- [TestMethod]
- [Priority(0)]
- [ExpectedException(typeof(ArgumentOutOfRangeException))]
- [Description("Check that an exception is thrown when JetGrowDatabase a negative page count")]
- public void VerifyJetGrowDatabaseThrowsExceptionWhenDesiredPagesIsNegative()
- {
- int ignored;
- Api.JetGrowDatabase(JET_SESID.Nil, JET_DBID.Nil, -1, out ignored);
- }
-
- /// <summary>
- /// Check that an exception is thrown when JetSetDatabaseSize gets a
- /// null database name.
- /// </summary>
- [TestMethod]
- [Priority(0)]
- [ExpectedException(typeof(ArgumentNullException))]
- [Description("Check that an exception is thrown when JetSetDatabaseSize gets null database name")]
- public void JetSetDatabaseSizeThrowsExceptionWhenDatabaseNameIsNull()
- {
- int ignored;
- Api.JetSetDatabaseSize(this.sesid, null, 0, out ignored);
- }
-
- /// <summary>
- /// Check that an exception is thrown when JetSetDatabaseSize gets
- /// a negative page count.
- /// </summary>
- [TestMethod]
- [Priority(0)]
- [ExpectedException(typeof(ArgumentOutOfRangeException))]
- [Description("Check that an exception is thrown when JetSetDatabaseSize a negative page count")]
- public void VerifyJetSetDatabaseSizeThrowsExceptionWhenDesiredPagesIsNegative()
- {
- int ignored;
- Api.JetSetDatabaseSize(this.sesid, "foo.edb", -1, out ignored);
- }
-
- /// <summary>
- /// JetCompact should throw an exception when
- /// the source database is null.
- /// </summary>
- [TestMethod]
- [Priority(0)]
- [Description("JetCompact should throw an exception when the source database is null")]
- [ExpectedException(typeof(ArgumentNullException))]
- public void TestJetCompactThrowsExceptionWhenSourceIsNull()
- {
- Api.JetCompact(this.sesid, null, "destination", null, null, CompactGrbit.None);
- }
-
- /// <summary>
- /// JetCompact should throw an exception when
- /// the source database is null.
- /// </summary>
- [TestMethod]
- [Priority(0)]
- [Description("JetCompact should throw an exception when the source database is null")]
- [ExpectedException(typeof(ArgumentNullException))]
- public void TestJetCompactThrowsExceptionWhenDestinationIsNull()
- {
- Api.JetCompact(this.sesid, "source", null, null, null, CompactGrbit.None);
- }
-
- /// <summary>
- /// JetCompact should throw an exception when
- /// the ignored parameter is non-null.
- /// </summary>
- [TestMethod]
- [Priority(0)]
- [Description("JetCompact should throw an exception when the ignored parameter is non-null")]
- [ExpectedException(typeof(ArgumentException))]
- public void TestJetCompactThrowsExceptionWhenIgnoredIsNonNull()
- {
- #pragma warning disable 618,612 // JET_CONVERT is obsolete
- Api.JetCompact(this.sesid, "source", "destination", null, new Converter(), CompactGrbit.None);
- #pragma warning restore 618,612
- }
-
- #endregion Database API
-
- #region Streaming Backup/Restore
-
- /// <summary>
- /// Check that an exception is thrown when JetOpenFileInstance gets a
- /// null file name.
- /// </summary>
- [TestMethod]
- [Priority(0)]
- [ExpectedException(typeof(ArgumentNullException))]
- [Description("Check that an exception is thrown when JetOpenFileInstance gets a null file name")]
- public void JetOpenFileInstanceThrowsExceptionWhenFileNameIsNull()
- {
- JET_HANDLE handle;
- long fileSizeLow;
- long fileSizeHigh;
- Api.JetOpenFileInstance(this.instance, null, out handle, out fileSizeLow, out fileSizeHigh);
- }
-
- /// <summary>
- /// Check that an exception is thrown when JetReadFileInstance gets a
- /// null buffer.
- /// </summary>
- [TestMethod]
- [Priority(0)]
- [ExpectedException(typeof(ArgumentNullException))]
- [Description("Check that an exception is thrown when JetReadFileInstance gets a null buffer")]
- public void JetReadFileInstanceThrowsExceptionWhenBufferIsNull()
- {
- int bytesRead;
- Api.JetReadFileInstance(this.instance, JET_HANDLE.Nil, null, 0, out bytesRead);
- }
-
- /// <summary>
- /// Check that an exception is thrown when JetReadFileInstance gets a
- /// negative buffer size.
- /// </summary>
- [TestMethod]
- [Priority(0)]
- [ExpectedException(typeof(ArgumentOutOfRangeException))]
- [Description("Check that an exception is thrown when JetReadFileInstance gets a negative buffer size")]
- public void JetReadFileInstanceThrowsExceptionWhenBufferSizeIsNegative()
- {
- int bytesRead;
- Api.JetReadFileInstance(this.instance, JET_HANDLE.Nil, new byte[1], -1, out bytesRead);
- }
-
- /// <summary>
- /// Check that an exception is thrown when JetReadFileInstance gets a
- /// buffer size that is too long.
- /// </summary>
- [TestMethod]
- [Priority(0)]
- [ExpectedException(typeof(ArgumentOutOfRangeException))]
- [Description("Check that an exception is thrown when JetReadFileInstance gets a buffer size that is too long")]
- public void JetReadFileInstanceThrowsExceptionWhenBufferSizeIsTooLong()
- {
- int bytesRead;
- Api.JetReadFileInstance(this.instance, JET_HANDLE.Nil, new byte[1], 2, out bytesRead);
- }
-
- /// <summary>
- /// Check that an exception is thrown when JetGetAttachInfoInstance gets a buffer size that is negative.
- /// </summary>
- [TestMethod]
- [Priority(0)]
- [ExpectedException(typeof(ArgumentOutOfRangeException))]
- [Description("Check that an exception is thrown when JetGetAttachInfoInstance gets a buffer size that is negative")]
- public void JetGetAttachInfoInstanceThrowsExceptionWhenMaxCharsIsNegative()
- {
- string ignored;
- int ignored2;
- Api.JetGetAttachInfoInstance(this.instance, out ignored, -1, out ignored2);
- }
-
- /// <summary>
- /// Check that an exception is thrown when JetGetAttachInfoInstance gets a
- /// too large max param value.
- /// </summary>
- [TestMethod]
- [Priority(0)]
- [ExpectedException(typeof(OverflowException))]
- [Description("Check that an exception is thrown when JetGetAttachInfoInstance gets a too large max param value")]
- public void JetGetAttachInfoInstanceThrowsExceptionWhenMaxParamIsTooBig()
- {
- // This test only fails with the Unicode API (the overflow happens when we try
- // to multiply maxParam by sizeof(char))
- if (!EsentVersion.SupportsUnicodePaths)
- {
- throw new OverflowException();
- }
-
- string ignored;
- int ignored2;
- Api.JetGetAttachInfoInstance(this.instance, out ignored, Int32.MaxValue, out ignored2);
- }
-
- /// <summary>
- /// Check that an exception is thrown when JetGetLogInfoInstance gets a buffer size that is negative.
- /// </summary>
- [TestMethod]
- [Priority(0)]
- [ExpectedException(typeof(ArgumentOutOfRangeException))]
- [Description("Check that an exception is thrown when JetGetLogInfoInstance gets a buffer size that is negative")]
- public void JetGetLogInfoInstanceThrowsExceptionWhenMaxCharsIsNegative()
- {
- string ignored;
- int ignored2;
- Api.JetGetLogInfoInstance(this.instance, out ignored, -1, out ignored2);
- }
-
- /// <summary>
- /// Check that an exception is thrown when JetGetLogInfoInstance gets a
- /// too large max param value.
- /// </summary>
- [TestMethod]
- [Priority(0)]
- [ExpectedException(typeof(OverflowException))]
- [Description("Check that an exception is thrown when JetGetLogInfoInstance gets a too large max param value")]
- public void JetGetLogInfoInstanceThrowsExceptionWhenMaxParamIsTooBig()
- {
- // This test only fails with the Unicode API (the overflow happens when we try
- // to multiply maxParam by sizeof(char))
- if (!EsentVersion.SupportsUnicodePaths)
- {
- throw new OverflowException();
- }
-
- string ignored;
- int ignored2;
- Api.JetGetLogInfoInstance(this.instance, out ignored, Int32.MaxValue, out ignored2);
- }
-
- /// <summary>
- /// Check that an exception is thrown when JetGetTruncateLogInfoInstance gets a buffer size that is negative.
- /// </summary>
- [TestMethod]
- [Priority(0)]
- [ExpectedException(typeof(ArgumentOutOfRangeException))]
- [Description("Check that an exception is thrown when JetGetTruncateLogInfoInstance gets a buffer size that is negative")]
- public void JetGetTruncateLogInfoInstanceThrowsExceptionWhenMaxCharsIsNegative()
- {
- string ignored;
- int ignored2;
- Api.JetGetTruncateLogInfoInstance(this.instance, out ignored, -1, out ignored2);
- }
-
- /// <summary>
- /// Check that an exception is thrown when JetGetTruncateLogInfoInstance gets a
- /// too large max param value.
- /// </summary>
- [TestMethod]
- [Priority(0)]
- [ExpectedException(typeof(OverflowException))]
- [Description("Check that an exception is thrown when JetGetTruncateLogInfoInstance gets a too large max param value")]
- public void JetGetTruncateLogInfoInstanceThrowsExceptionWhenMaxParamIsTooBig()
- {
- // This test only fails with the Unicode API (the overflow happens when we try
- // to multiply maxParam by sizeof(char))
- if (!EsentVersion.SupportsUnicodePaths)
- {
- throw new OverflowException();
- }
-
- string ignored;
- int ignored2;
- Api.JetGetTruncateLogInfoInstance(this.instance, out ignored, Int32.MaxValue, out ignored2);
- }
-
- #endregion
-
- #region DDL
-
- /// <summary>
- /// Check that an exception is thrown when JetOpenTable gets a
- /// null table name.
- /// </summary>
- [TestMethod]
- [Priority(0)]
- [Description("Check that an exception is thrown when JetOpenTable gets a null table name")]
- [ExpectedException(typeof(ArgumentNullException))]
- public void JetOpenTableThrowsExceptionWhenTableNameIsNull()
- {
- JET_TABLEID ignoredTableid;
- Api.JetOpenTable(this.sesid, this.dbid, null, null, 0, OpenTableGrbit.None, out ignoredTableid);
- }
-
- /// <summary>
- /// Check that an exception is thrown when JetOpenTable gets a
- /// parameters size that is too long.
- /// </summary>
- [TestMethod]
- [Priority(0)]
- [Description("Check that an exception is thrown when JetOpenTable gets a parameters size that is too long")]
- [ExpectedException(typeof(ArgumentOutOfRangeException))]
- public void JetOpenTableThrowsExceptionWhenParametersSizeIsTooLong()
- {
- byte[] parameters = new byte[1];
- JET_TABLEID ignoredTableid;
- Api.JetOpenTable(this.sesid, this.dbid, "table", parameters, parameters.Length + 1, OpenTableGrbit.None, out ignoredTableid);
- }
-
- /// <summary>
- /// Check that an exception is thrown when JetCreateTable gets a
- /// null table name.
- /// </summary>
- [TestMethod]
- [Priority(0)]
- [Description("Check that an exception is thrown when JetCreateTable gets a null table name")]
- [ExpectedException(typeof(ArgumentNullException))]
- public void JetCreateTableThrowsExceptionWhenTableNameIsNull()
- {
- JET_TABLEID ignoredTableid;
- Api.JetCreateTable(this.sesid, this.dbid, null, 0, 100, out ignoredTableid);
- }
-
- /// <summary>
- /// Check that an exception is thrown when JetDeleteTable gets a
- /// null table name.
- /// </summary>
- [TestMethod]
- [Priority(0)]
- [Description("Check that an exception is thrown when JetDeleteTable gets a null table name")]
- [ExpectedException(typeof(ArgumentNullException))]
- public void JetDeleteTableThrowsExceptionWhenTableNameIsNull()
- {
- Api.JetDeleteTable(this.sesid, this.dbid, null);
- }
-
- /// <summary>
- /// Check that an exception is thrown when JetGetTableInfo gets a
- /// null result buffer.
- /// </summary>
- [TestMethod]
- [Priority(0)]
- [Description("Check that an exception is thrown when JetGetTableInfo gets a null result buffer")]
- [ExpectedException(typeof(ArgumentNullException))]
- public void JetGetTableInfoThrowsExceptionWhenResultIsNull()
- {
- Api.JetGetTableInfo(this.sesid, this.tableid, null, JET_TblInfo.SpaceUsage);
- }
-
- /// <summary>
- /// Check that an exception is thrown when JetGetColumnInfo gets a
- /// null table name.
- /// </summary>
- [TestMethod]
- [Priority(0)]
- [Description("Check that an exception is thrown when JetGetColumnInfo gets a null table name")]
- [ExpectedException(typeof(ArgumentNullException))]
- public void JetGetColumnInfoThrowsExceptionWhenTableNameIsNull()
- {
- JET_COLUMNDEF columndef;
- Api.JetGetColumnInfo(this.sesid, this.dbid, null, "column", out columndef);
- }
-
- /// <summary>
- /// Check that an exception is thrown when JetGetColumnInfo gets a
- /// null column name.
- /// </summary>
- [TestMethod]
- [Priority(0)]
- [Description("Check that an exception is thrown when JetGetColumnInfo gets a null column name")]
- [ExpectedException(typeof(ArgumentNullException))]
- public void JetGetColumnInfoThrowsExceptionWhenColumnNameIsNull()
- {
- JET_COLUMNDEF columndef;
- Api.JetGetColumnInfo(this.sesid, this.dbid, "table", null, out columndef);
- }
-
- /// <summary>
- /// Check that an exception is thrown when JetGetColumnInfo gets a
- /// null table name.
- /// </summary>
- /// <remarks>
- /// This tests the version of the API that takes a JET_COLUMNLIST.
- /// </remarks>
- [TestMethod]
- [Priority(0)]
- [Description("Check that an exception is thrown when JetGetColumnInfo gets a null table name")]
- [ExpectedException(typeof(ArgumentNullException))]
- public void JetGetColumnInfoThrowsExceptionWhenTableNameIsNull2()
- {
- JET_COLUMNLIST columnlist;
- Api.JetGetColumnInfo(this.sesid, this.dbid, null, null, out columnlist);
- }
-
- /// <summary>
- /// Check that an exception is thrown when JetGetColumnInfo gets a
- /// null table name.
- /// </summary>
- /// <remarks>
- /// This tests the version of the API that takes a JET_COLUMNBASE.
- /// </remarks>
- [TestMethod]
- [Priority(0)]
- [Description("Check that an exception is thrown when JetGetColumnInfo gets a null table name")]
- [ExpectedException(typeof(ArgumentNullException))]
- public void JetGetColumnInfoThrowsExceptionWhenTableNameIsNull3()
- {
- JET_COLUMNBASE columnbase;
- Api.JetGetColumnInfo(this.sesid, this.dbid, null, null, out columnbase);
- }
-
- /// <summary>
- /// Check that an exception is thrown when JetGetTableColumnInfo gets a
- /// null column name.
- /// </summary>
- [TestMethod]
- [Priority(0)]
- [Description("Check that an exception is thrown when JetGetTableColumnInfo gets a null column name")]
- [ExpectedException(typeof(ArgumentNullException))]
- public void JetGetTableColumnInfoThrowsExceptionWhenColumnNameIsNull()
- {
- JET_COLUMNDEF columndef;
- Api.JetGetTableColumnInfo(this.sesid, this.tableid, null, out columndef);
- }
-
- /// <summary>
- /// Check that an exception is thrown when JetGetIndexInfo gets a
- /// null table name.
- /// </summary>
- [TestMethod]
- [Priority(0)]
- [Description("Check that an exception is thrown when JetGetIndexInfo(obsolete) gets a null table name")]
- [ExpectedException(typeof(ArgumentNullException))]
- public void JetGetIndexInfoObsoleteThrowsExceptionWhenTableNameIsNull()
- {
- JET_INDEXLIST indexlist;
- #pragma warning disable 612,618 // Obsolete
- Api.JetGetIndexInfo(this.sesid, this.dbid, null, String.Empty, out indexlist);
- #pragma warning restore 612,618
- }
-
- /// <summary>
- /// Check that an exception is thrown when JetGetIndexInfo gets a
- /// null table name.
- /// </summary>
- [TestMethod]
- [Priority(0)]
- [Description("Check that an exception is thrown when JetGetIndexInfo(ushort) gets a null table name")]
- [ExpectedException(typeof(ArgumentNullException))]
- public void JetGetIndexInfoUshortThrowsExceptionWhenTableNameIsNull()
- {
- ushort result;
- Api.JetGetIndexInfo(this.sesid, this.dbid, null, String.Empty, out result, JET_IdxInfo.Default);
- }
-
- /// <summary>
- /// Check that an exception is thrown when JetGetIndexInfo gets a
- /// null table name.
- /// </summary>
- [TestMethod]
- [Priority(0)]
- [Description("Check that an exception is thrown when JetGetIndexInfo(int) gets a null table name")]
- [ExpectedException(typeof(ArgumentNullException))]
- public void JetGetIndexInfoIntThrowsExceptionWhenTableNameIsNull()
- {
- int result;
- Api.JetGetIndexInfo(this.sesid, this.dbid, null, String.Empty, out result, JET_IdxInfo.Default);
- }
-
- /// <summary>
- /// Check that an exception is thrown when JetGetIndexInfo gets a
- /// null table name.
- /// </summary>
- [TestMethod]
- [Priority(0)]
- [Description("Check that an exception is thrown when JetGetIndexInfo(JET_INDEXID) gets a null table name")]
- [ExpectedException(typeof(ArgumentNullException))]
- public void JetGetIndexInfoIndexidThrowsExceptionWhenTableNameIsNull()
- {
- JET_INDEXID result;
- Api.JetGetIndexInfo(this.sesid, this.dbid, null, String.Empty, out result, JET_IdxInfo.Default);
- }
-
- /// <summary>
- /// Check that an exception is thrown when JetGetIndexInfo gets a
- /// null table name.
- /// </summary>
- [TestMethod]
- [Priority(0)]
- [Description("Check that an exception is thrown when JetGetIndexInfo(JET_INDEXLIST) gets a null table name")]
- [ExpectedException(typeof(ArgumentNullException))]
- public void JetGetIndexInfoIndexListThrowsExceptionWhenTableNameIsNull()
- {
- JET_INDEXLIST result;
- Api.JetGetIndexInfo(this.sesid, this.dbid, null, String.Empty, out result, JET_IdxInfo.Default);
- }
-
- /// <summary>
- /// Check that an exception is thrown when JetRenameTable gets a
- /// null table name.
- /// </summary>
- [TestMethod]
- [Priority(0)]
- [Description("Check that an exception is thrown when JetRenameTable gets a null table name")]
- [ExpectedException(typeof(ArgumentNullException))]
- public void JetRenameTableThrowsExceptionWhenTableNameIsNull()
- {
- Api.JetRenameTable(this.sesid, this.dbid, null, "newtable");
- }
-
- /// <summary>
- /// Check that an exception is thrown when JetRenameTable gets a
- /// null new table name.
- /// </summary>
- [TestMethod]
- [Priority(0)]
- [Description("Check that an exception is thrown when JetRenameTable gets a null new table name")]
- [ExpectedException(typeof(ArgumentNullException))]
- public void JetRenameTableThrowsExceptionWhenNewTableNameIsNull()
- {
- Api.JetRenameTable(this.sesid, this.dbid, "oldtable", null);
- }
-
- /// <summary>
- /// Verify that an exception is thrown when JetRenameColumn gets a
- /// null column name.
- /// </summary>
- [TestMethod]
- [Priority(0)]
- [Description("Verify that an exception is thrown when JetRenameColumn gets a null column name")]
- [ExpectedException(typeof(ArgumentNullException))]
- public void VerifyJetRenameColumnThrowsExceptionWhencolumnNameIsNull()
- {
- Api.JetRenameColumn(this.sesid, this.tableid, null, "newcolumn", RenameColumnGrbit.None);
- }
-
- /// <summary>
- /// Verify that an exception is thrown when JetRenameColumn gets a
- /// null new column name.
- /// </summary>
- [TestMethod]
- [Priority(0)]
- [Description("Verify that an exception is thrown when JetRenameColumn gets a null new column name")]
- [ExpectedException(typeof(ArgumentNullException))]
- public void VerifyJetRenameColumnThrowsExceptionWhenNewColumnNameIsNull()
- {
- Api.JetRenameColumn(this.sesid, this.tableid, "oldcolumn", null, RenameColumnGrbit.None);
- }
-
- /// <summary>
- /// Verify that an exception is thrown when JetSetColumnDefaultValue gets a null table name.
- /// </summary>
- [TestMethod]
- [Priority(0)]
- [Description(" Verify that an exception is thrown when JetSetColumnDefaultValue gets a null table name")]
- [ExpectedException(typeof(ArgumentNullException))]
- public void VerifyJetSetColumnDefaultValueThrowsExceptionWhenTableNameIsNull()
- {
- Api.JetSetColumnDefaultValue(this.sesid, this.dbid, null, "column", new byte[1], 1, SetColumnDefaultValueGrbit.None);
- }
-
- /// <summary>
- /// Verify that an exception is thrown when JetSetColumnDefaultValue gets a null column name.
- /// </summary>
- [TestMethod]
- [Priority(0)]
- [Description(" Verify that an exception is thrown when JetSetColumnDefaultValue gets a null column name")]
- [ExpectedException(typeof(ArgumentNullException))]
- public void VerifyJetSetColumnDefaultValueThrowsExceptionWhenColumnNameIsNull()
- {
- Api.JetSetColumnDefaultValue(this.sesid, this.dbid, "table", null, new byte[1], 1, SetColumnDefaultValueGrbit.None);
- }
-
- /// <summary>
- /// Verify that an exception is thrown when JetSetColumnDefaultValue gets a negative data size.
- /// </summary>
- [TestMethod]
- [Priority(0)]
- [Description("Verify that an exception is thrown when JetSetColumnDefaultValue gets a negative data size")]
- [ExpectedException(typeof(ArgumentOutOfRangeException))]
- public void VerifyJetSetColumnDefaultValueThrowsExceptionWhenDataSizeIsNegative()
- {
- Api.JetSetColumnDefaultValue(this.sesid, this.dbid, "table", "column", null, -1, SetColumnDefaultValueGrbit.None);
- }
-
- /// <summary>
- /// Verify that an exception is thrown when JetSetColumnDefaultValue gets a data size that is too long.
- /// </summary>
- [TestMethod]
- [Priority(0)]
- [Description("Verify that an exception is thrown when JetSetColumnDefaultValue gets a data size that is too long")]
- [ExpectedException(typeof(ArgumentOutOfRangeException))]
- public void VerifyJetSetColumnDefaultValueThrowsExceptionWhenDataSizeIsTooLong()
- {
- Api.JetSetColumnDefaultValue(this.sesid, this.dbid, "table", "column", new byte[1], 2, SetColumnDefaultValueGrbit.None);
- }
-
- /// <summary>
- /// Check that an exception is thrown when JetAddColumn gets a
- /// null column name.
- /// </summary>
- [TestMethod]
- [Priority(0)]
- [Description("Check that an exception is thrown when JetAddColumn gets a null column name")]
- [ExpectedException(typeof(ArgumentNullException))]
- public void JetAddColumnThrowsExceptionWhenColumnNameIsNull()
- {
- var columndef = new JET_COLUMNDEF()
- {
- coltyp = JET_coltyp.Binary,
- };
-
- JET_COLUMNID columnid;
- Api.JetAddColumn(
- this.sesid,
- this.tableid,
- null,
- columndef,
- null,
- 0,
- out columnid);
- }
-
- /// <summary>
- /// Check that an exception is thrown when JetAddColumn gets a
- /// null column definition.
- /// </summary>
- [TestMethod]
- [Priority(0)]
- [Description("Check that an exception is thrown when JetAddColumn gets a null column definition")]
- [ExpectedException(typeof(ArgumentNullException))]
- public void JetAddColumnThrowsExceptionWhenColumndefIsNull()
- {
- JET_COLUMNID columnid;
- Api.JetAddColumn(
- this.sesid,
- this.tableid,
- "column",
- null,
- null,
- 0,
- out columnid);
- }
-
- /// <summary>
- /// Check that an exception is thrown when JetAddColumn gets a
- /// default value length that is negative.
- /// </summary>
- [TestMethod]
- [Priority(0)]
- [Description("Check that an exception is thrown when JetAddColumn gets a default value length that is negative")]
- [ExpectedException(typeof(ArgumentOutOfRangeException))]
- public void JetAddColumnThrowsExceptionWhenDefaultValueLengthIsNegative()
- {
- var columndef = new JET_COLUMNDEF()
- {
- coltyp = JET_coltyp.Binary,
- };
-
- JET_COLUMNID columnid;
- Api.JetAddColumn(
- this.sesid,
- this.tableid,
- "NegativeDefaultValue",
- columndef,
- null,
- -1,
- out columnid);
- }
-
- /// <summary>
- /// Check that an exception is thrown when JetAddColumn gets a
- /// default value length that is too long.
- /// </summary>
- [TestMethod]
- [Priority(0)]
- [Description("Check that an exception is thrown when JetAddColumn gets a default value length that is too long")]
- [ExpectedException(typeof(ArgumentOutOfRangeException))]
- public void JetAddColumnThrowsExceptionWhenDefaultValueLengthIsTooLong()
- {
- var defaultValue = new byte[10];
- var columndef = new JET_COLUMNDEF()
- {
- coltyp = JET_coltyp.Binary,
- };
-
- JET_COLUMNID columnid;
- Api.JetAddColumn(
- this.sesid,
- this.tableid,
- "BadDefaultValue",
- columndef,
- defaultValue,
- defaultValue.Length + 1,
- out columnid);
- }
-
- /// <summary>
- /// Check that an exception is thrown when JetAddColumn gets a
- /// default value that is null with a non-zero default value size.
- /// </summary>
- [TestMethod]
- [Priority(0)]
- [Description("Check that an exception is thrown when JetAddColumn gets a default value that is null with a non-zero default value size")]
- [ExpectedException(typeof(ArgumentOutOfRangeException))]
- public void JetAddColumnThrowsExceptionWhenDefaultValueIsUnexpectedNull()
- {
- var defaultValue = new byte[10];
- var columndef = new JET_COLUMNDEF()
- {
- coltyp = JET_coltyp.Binary,
- };
-
- JET_COLUMNID columnid;
- Api.JetAddColumn(
- this.sesid,
- this.tableid,
- "BadDefaultValue",
- columndef,
- null,
- 1,
- out columnid);
- }
-
- /// <summary>
- /// Check that an exception is thrown when JetCreateIndex gets a
- /// null name.
- /// </summary>
- [TestMethod]
- [Priority(0)]
- [Description("Check that an exception is thrown when JetCreateIndex gets a null name")]
- [ExpectedException(typeof(ArgumentNullException))]
- public void JetCreateIndexThrowsExceptionWhenNameIsNull()
- {
- Api.JetCreateIndex(this.sesid, this.tableid, null, CreateIndexGrbit.None, "+foo\0", 6, 100);
- }
-
- /// <summary>
- /// Check that an exception is thrown when JetCreateIndex gets a
- /// density that is negative.
- /// </summary>
- [TestMethod]
- [Priority(0)]
- [Description("Check that an exception is thrown when JetCreateIndex gets a density that is negative")]
- [ExpectedException(typeof(ArgumentOutOfRangeException))]
- public void JetCreateIndexThrowsExceptionWhenDensityIsNegative()
- {
- Api.JetCreateIndex(this.sesid, this.tableid, "BadIndex,", CreateIndexGrbit.None, "+foo\0", 6, -1);
- }
-
- /// <summary>
- /// Check that an exception is thrown when JetCreateIndex gets a
- /// key description length that is negative.
- /// </summary>
- [TestMethod]
- [Priority(0)]
- [Description("Check that an exception is thrown when JetCreateIndex gets a key description length that is negative")]
- [ExpectedException(typeof(ArgumentOutOfRangeException))]
- public void JetCreateIndexThrowsExceptionWhenKeyDescriptionLengthIsNegative()
- {
- Api.JetCreateIndex(this.sesid, this.tableid, "BadIndex,", CreateIndexGrbit.None, "+foo\0", -1, 100);
- }
-
- /// <summary>
- /// Check that an exception is thrown when JetCreateIndex gets a
- /// key description length that is too long.
- /// </summary>
- [TestMethod]
- [Priority(0)]
- [Description("Check that an exception is thrown when JetCreateIndex gets a key description length that is too long")]
- [ExpectedException(typeof(ArgumentOutOfRangeException))]
- public void JetCreateIndexThrowsExceptionWhenKeyDescriptionLengthIsTooLong()
- {
- Api.JetCreateIndex(this.sesid, this.tableid, "BadIndex,", CreateIndexGrbit.None, "+foo\0", 77, 100);
- }
-
- /// <summary>
- /// Check that an exception is thrown when JetCreateIndex2 gets
- /// null indexcreates.
- /// </summary>
- [TestMethod]
- [Priority(0)]
- [Description("Check that an exception is thrown when JetCreateIndex2 gets null indexcreates")]
- [ExpectedException(typeof(ArgumentNullException))]
- public void JetCreateIndex2ThrowsExceptionWhenIndexcreatesAreNull()
- {
- Api.JetCreateIndex2(this.sesid, this.tableid, null, 0);
- }
-
- /// <summary>
- /// Check that an exception is thrown when JetCreateIndex2 gets
- /// a negative indexcreate count.
- /// </summary>
- [TestMethod]
- [Priority(0)]
- [Description("Check that an exception is thrown when JetCreateIndex2 gets a negative indexcreate count")]
- [ExpectedException(typeof(ArgumentOutOfRangeException))]
- public void JetCreateIndex2ThrowsExceptionWhenNumIndexcreatesIsNegative()
- {
- var indexcreates = new[] { new JET_INDEXCREATE() };
- Api.JetCreateIndex2(this.sesid, this.tableid, indexcreates, -1);
- }
-
- /// <summary>
- /// Check that an exception is thrown when JetCreateIndex2 gets
- /// an indexcreate count that is too long.
- /// </summary>
- [TestMethod]
- [Priority(0)]
- [Description("Check that an exception is thrown when JetCreateIndex2 gets an indexcreate count that is too long")]
- [ExpectedException(typeof(ArgumentOutOfRangeException))]
- public void JetCreateIndex2ThrowsExceptionWhenNumIndexcreatesIsTooLong()
- {
- var indexcreates = new[] { new JET_INDEXCREATE() };
- Api.JetCreateIndex2(this.sesid, this.tableid, indexcreates, indexcreates.Length + 1);
- }
-
- /// <summary>
- /// Check that an exception is thrown when JetCreateIndex2 gets a
- /// null index name.
- /// </summary>
- [TestMethod]
- [Priority(0)]
- [Description("Check that an exception is thrown when JetCreateIndex2 gets a null index name")]
- [ExpectedException(typeof(ArgumentNullException))]
- public void JetCreateIndex2ThrowsExceptionWhenIndexNameIsNull()
- {
- const string Key = "+column\0";
- var indexcreates = new[]
- {
- new JET_INDEXCREATE
- {
- cbKey = Key.Length,
- szKey = Key,
- },
- };
- Api.JetCreateIndex2(this.sesid, this.tableid, indexcreates, indexcreates.Length);
- }
-
- /// <summary>
- /// Check that an exception is thrown when JetDeleteColumn gets a
- /// null column name.
- /// </summary>
- [TestMethod]
- [Priority(0)]
- [Description("Check that an exception is thrown when JetDeleteColumn gets a null column name")]
- [ExpectedException(typeof(ArgumentNullException))]
- public void JetDeleteColumnThrowsExceptionWhenColumnNameIsNull()
- {
- Api.JetDeleteColumn(this.sesid, this.tableid, null);
- }
-
- /// <summary>
- /// Check that an exception is thrown when JetDeleteColumn gets a
- /// null column name.
- /// </summary>
- [TestMethod]
- [Priority(0)]
- [Description("Check that an exception is thrown when JetDeleteColumn gets a null column name")]
- [ExpectedException(typeof(ArgumentNullException))]
- public void JetDeleteColumn2ThrowsExceptionWhenColumnNameIsNull()
- {
- Api.JetDeleteColumn2(this.sesid, this.tableid, null, DeleteColumnGrbit.None);
- }
-
- /// <summary>
- /// Check that an exception is thrown when JetDeleteIndex gets a
- /// null index name.
- /// </summary>
- [TestMethod]
- [Priority(0)]
- [Description("Check that an exception is thrown when JetDeleteIndex gets a null index name")]
- [ExpectedException(typeof(ArgumentNullException))]
- public void JetDeleteIndexThrowsExceptionWhenIndexNameIsNull()
- {
- Api.JetDeleteIndex(this.sesid, this.tableid, null);
- }
-
- #endregion
-
- #region Meta-data Helpers
-
- /// <summary>
- /// Verify that an exception is thrown when TryOpenTable gets a null table name.
- /// </summary>
- [TestMethod]
- [Priority(0)]
- [Description("Verify that an exception is thrown when TryOpenTable gets a null table name")]
- [ExpectedException(typeof(ArgumentNullException))]
- public void VerifyTryOpenTableThrowsExceptionWhenTableNameIsNull()
- {
- JET_TABLEID t;
- Api.TryOpenTable(this.sesid, this.dbid, null, OpenTableGrbit.None, out t);
- }
-
- /// <summary>
- /// Verify that an exception is thrown when GetTableColumnid gets a null column name.
- /// </summary>
- [TestMethod]
- [Priority(0)]
- [Description("Verify that an exception is thrown when GetTableColumnid gets a null column name")]
- [ExpectedException(typeof(ArgumentNullException))]
- public void VerifyGetTableColumnidThrowsExceptionWhenColumnNameIsNull()
- {
- Api.GetTableColumnid(this.sesid, this.tableid, null);
- }
-
- /// <summary>
- /// Verify that an exception is thrown when GetTableColumns gets a null table name.
- /// </summary>
- [TestMethod]
- [Priority(0)]
- [Description("Verify that an exception is thrown when GetTableColumns gets a null table name")]
- [ExpectedException(typeof(ArgumentNullException))]
- public void VerifyGetTableColumnsThrowsExceptionWhenTableNameIsNull()
- {
- Api.GetTableColumns(this.sesid, this.dbid, null);
- }
-
- /// <summary>
- /// Verify that an exception is thrown when GetTableIndexes gets a null table name.
- /// </summary>
- [TestMethod]
- [Priority(0)]
- [Description("Verify that an exception is thrown when GetTableIndexes gets a null table name")]
- [ExpectedException(typeof(ArgumentNullException))]
- public void VerifyGetTableIndexesThrowsExceptionWhenTableNameIsNull()
- {
- Api.GetTableIndexes(this.sesid, this.dbid, null);
- }
-
- #endregion
-
- #region Temporary Table Creation
-
- /// <summary>
- /// Null columns is invalid.
- /// </summary>
- [TestMethod]
- [Priority(0)]
- [Description("Verify JetOpenTempTable throws an Exception when columns parameter is null")]
- [ExpectedException(typeof(ArgumentNullException))]
- public void VerifyJetOpenTempTableThrowsExceptionWhenColumnsIsNull()
- {
- JET_TABLEID tableidIgnored;
- var columnids = new JET_COLUMNID[1];
- Api.JetOpenTempTable(this.sesid, null, 0, TempTableGrbit.None, out tableidIgnored, columnids);
- }
-
- /// <summary>
- /// Null columnids is invalid.
- /// </summary>
- [TestMethod]
- [Priority(0)]
- [ExpectedException(typeof(ArgumentNullException))]
- [Description("Verify JetOpenTempTable throws an Exception when columnids parameter is null")]
- public void VerifyJetOpenTempTableThrowsExceptionWhenColumnidsIsNull()
- {
- JET_TABLEID tableidIgnored;
- var columns = new[] { new JET_COLUMNDEF() };
- Api.JetOpenTempTable(this.sesid, columns, columns.Length, TempTableGrbit.None, out tableidIgnored, null);
- }
-
- /// <summary>
- /// Columnids must match columndefs in length.
- /// </summary>
- [TestMethod]
- [Priority(0)]
- [ExpectedException(typeof(ArgumentOutOfRangeException))]
- [Description("Verify JetOpenTempTable throws an Exception when columnids parameter is the wrong length")]
- public void VerifyJetOpenTempTableThrowsExceptionWhenColumnidsIsTooShort()
- {
- JET_TABLEID tableidIgnored;
- var columns = new[] { new JET_COLUMNDEF(), new JET_COLUMNDEF() };
- var columnids = new JET_COLUMNID[columns.Length - 1];
- Api.JetOpenTempTable(this.sesid, columns, columns.Length, TempTableGrbit.None, out tableidIgnored, columnids);
- }
-
- /// <summary>
- /// Negative column count is invalid.
- /// </summary>
- [TestMethod]
- [Priority(0)]
- [ExpectedException(typeof(ArgumentOutOfRangeException))]
- [Description("Verify JetOpenTempTable throws an Exception when column count is negative")]
- public void VerifyJetOpenTempTableThrowsExceptionWhenColumnCountIsNegative()
- {
- JET_TABLEID tableidIgnored;
- var columns = new[] { new JET_COLUMNDEF() };
- var columnids = new JET_COLUMNID[1];
- Api.JetOpenTempTable(this.sesid, columns, -1, TempTableGrbit.None, out tableidIgnored, columnids);
- }
-
- /// <summary>
- /// Too-long column count is invalid.
- /// </summary>
- [TestMethod]
- [Priority(0)]
- [Description("Verify JetOpenTempTable throws an Exception when column count is too long")]
- [ExpectedException(typeof(ArgumentOutOfRangeException))]
- public void VerifyJetOpenTempTableThrowsExceptionWhenColumnCountIsTooLong()
- {
- JET_TABLEID tableidIgnored;
- var columns = new[] { new JET_COLUMNDEF() };
- var columnids = new JET_COLUMNID[1];
- Api.JetOpenTempTable(this.sesid, columns, 2, TempTableGrbit.None, out tableidIgnored, columnids);
- }
-
- /// <summary>
- /// Null columns is invalid.
- /// </summary>
- [TestMethod]
- [Priority(0)]
- [Description("Verify JetOpenTempTable2 throws an Exception when columns parameter is null")]
- [ExpectedException(typeof(ArgumentNullException))]
- public void VerifyJetOpenTempTable2ThrowsExceptionWhenColumnsIsNull()
- {
- JET_TABLEID tableidIgnored;
- var columnids = new JET_COLUMNID[1];
- Api.JetOpenTempTable2(this.sesid, null, 0, 1033, TempTableGrbit.None, out tableidIgnored, columnids);
- }
-
- /// <summary>
- /// Null columnids is invalid.
- /// </summary>
- [TestMethod]