/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

  1. //-----------------------------------------------------------------------
  2. // <copyright file="ParameterCheckingTests.cs" company="Microsoft Corporation">
  3. // Copyright (c) Microsoft Corporation.
  4. // </copyright>
  5. //-----------------------------------------------------------------------
  6. namespace InteropApiTests
  7. {
  8. using System;
  9. using System.Linq;
  10. using Microsoft.Isam.Esent.Interop;
  11. using Microsoft.Isam.Esent.Interop.Server2003;
  12. using Microsoft.Isam.Esent.Interop.Vista;
  13. using Microsoft.Isam.Esent.Interop.Windows7;
  14. using Microsoft.VisualStudio.TestTools.UnitTesting;
  15. /// <summary>
  16. /// Test for API parameter validation code
  17. /// </summary>
  18. [TestClass]
  19. public class ParameterCheckingTests
  20. {
  21. /// <summary>
  22. /// The instance used by the test.
  23. /// </summary>
  24. private readonly JET_INSTANCE instance = JET_INSTANCE.Nil;
  25. /// <summary>
  26. /// The session used by the test.
  27. /// </summary>
  28. private readonly JET_SESID sesid = JET_SESID.Nil;
  29. /// <summary>
  30. /// The table used by the test.
  31. /// </summary>
  32. private readonly JET_TABLEID tableid = JET_TABLEID.Nil;
  33. /// <summary>
  34. /// The columnid used by the test.
  35. /// </summary>
  36. private readonly JET_COLUMNID columnid = JET_COLUMNID.Nil;
  37. /// <summary>
  38. /// Identifies the database used by the test.
  39. /// </summary>
  40. private readonly JET_DBID dbid = JET_DBID.Nil;
  41. #region Setup/Teardown
  42. /// <summary>
  43. /// Verifies no instances are leaked.
  44. /// </summary>
  45. [TestCleanup]
  46. public void Teardown()
  47. {
  48. SetupHelper.CheckProcessForInstanceLeaks();
  49. }
  50. #endregion
  51. #region System Parameter tests
  52. /// <summary>
  53. /// Check that an exception is thrown when JetGetSystemParameter gets a
  54. /// negative max param value.
  55. /// </summary>
  56. [TestMethod]
  57. [Priority(0)]
  58. [ExpectedException(typeof(ArgumentOutOfRangeException))]
  59. [Description("Check that an exception is thrown when JetGetSystemParameter gets a negative max param value")]
  60. public void JetGetSystemParameterThrowsExceptionWhenMaxParamIsNegative()
  61. {
  62. int ignored = 0;
  63. string value;
  64. Api.JetGetSystemParameter(this.instance, this.sesid, JET_param.SystemPath, ref ignored, out value, -1);
  65. }
  66. /// <summary>
  67. /// Check that an exception is thrown when JetGetSystemParameter gets a
  68. /// too large max param value.
  69. /// </summary>
  70. [TestMethod]
  71. [Priority(0)]
  72. [ExpectedException(typeof(OverflowException))]
  73. [Description("Check that an exception is thrown when JetGetSystemParameter gets a too large max param value")]
  74. public void JetGetSystemParameterThrowsExceptionWhenMaxParamIsTooBig()
  75. {
  76. // This test only fails with the Unicode API (the overflow happens when we try
  77. // to multiply maxParam by sizeof(char))
  78. if (!EsentVersion.SupportsUnicodePaths)
  79. {
  80. throw new OverflowException();
  81. }
  82. int ignored = 0;
  83. string value;
  84. Api.JetGetSystemParameter(this.instance, this.sesid, JET_param.SystemPath, ref ignored, out value, Int32.MaxValue);
  85. }
  86. #endregion
  87. #region Database API
  88. /// <summary>
  89. /// Check that an exception is thrown when JetCreateDatabase gets a
  90. /// null database name.
  91. /// </summary>
  92. [TestMethod]
  93. [Priority(0)]
  94. [ExpectedException(typeof(ArgumentNullException))]
  95. [Description("Check that an exception is thrown when JetCreateDatabase gets a null database name")]
  96. public void JetCreateDatabaseThrowsExceptionWhenDatabaseNameIsNull()
  97. {
  98. JET_DBID dbid;
  99. Api.JetCreateDatabase(this.sesid, null, null, out dbid, CreateDatabaseGrbit.None);
  100. }
  101. /// <summary>
  102. /// Check that an exception is thrown when JetCreateDatabase2 gets a
  103. /// null database name.
  104. /// </summary>
  105. [TestMethod]
  106. [Priority(0)]
  107. [ExpectedException(typeof(ArgumentNullException))]
  108. [Description("Check that an exception is thrown when JetCreateDatabase2 gets a null database name")]
  109. public void JetCreateDatabase2ThrowsExceptionWhenDatabaseNameIsNull()
  110. {
  111. JET_DBID dbid;
  112. Api.JetCreateDatabase2(this.sesid, null, 0, out dbid, CreateDatabaseGrbit.None);
  113. }
  114. /// <summary>
  115. /// Check that an exception is thrown when JetCreateDatabase2 gets a
  116. /// null database name.
  117. /// </summary>
  118. [TestMethod]
  119. [Priority(0)]
  120. [ExpectedException(typeof(ArgumentOutOfRangeException))]
  121. [Description("Check that an exception is thrown when JetCreateDatabase2 gets a negative page count")]
  122. public void JetCreateDatabase2ThrowsExceptionWhenPageCountIsNegative()
  123. {
  124. JET_DBID dbid;
  125. Api.JetCreateDatabase2(this.sesid, "foo.db", -2, out dbid, CreateDatabaseGrbit.None);
  126. }
  127. /// <summary>
  128. /// Check that an exception is thrown when JetAttachDatabase gets a
  129. /// null database name.
  130. /// </summary>
  131. [TestMethod]
  132. [Priority(0)]
  133. [ExpectedException(typeof(ArgumentNullException))]
  134. [Description("Check that an exception is thrown when JetAttachDatabase gets a null database name")]
  135. public void JetAttachDatabaseThrowsExceptionWhenDatabaseNameIsNull()
  136. {
  137. Api.JetAttachDatabase(this.sesid, null, AttachDatabaseGrbit.None);
  138. }
  139. /// <summary>
  140. /// Check that an exception is thrown when JetAttachDatabase2 gets a
  141. /// null database name.
  142. /// </summary>
  143. [TestMethod]
  144. [Priority(0)]
  145. [ExpectedException(typeof(ArgumentNullException))]
  146. [Description("Check that an exception is thrown when JetAttachDatabase2 gets null database name")]
  147. public void JetAttachDatabase2ThrowsExceptionWhenDatabaseNameIsNull()
  148. {
  149. Api.JetAttachDatabase2(this.sesid, null, 0, AttachDatabaseGrbit.None);
  150. }
  151. /// <summary>
  152. /// Check that an exception is thrown when JetAttachDatabase2 gets a
  153. /// negative max page count.
  154. /// </summary>
  155. [TestMethod]
  156. [Priority(0)]
  157. [ExpectedException(typeof(ArgumentOutOfRangeException))]
  158. [Description("Check that an exception is thrown when JetAttachDatabase2 gets negative max page count")]
  159. public void JetAttachDatabase2ThrowsExceptionWhenMaxPagesIsNegative()
  160. {
  161. Api.JetAttachDatabase2(this.sesid, "foo.db", -1, AttachDatabaseGrbit.None);
  162. }
  163. /// <summary>
  164. /// Check that an exception is thrown when JetOpenDatabase gets a
  165. /// null database name.
  166. /// </summary>
  167. [TestMethod]
  168. [Priority(0)]
  169. [ExpectedException(typeof(ArgumentNullException))]
  170. [Description("Check that an exception is thrown when JetOpenDatabase gets null database name")]
  171. public void JetOpenDatabaseThrowsExceptionWhenDatabaseNameIsNull()
  172. {
  173. JET_DBID dbid;
  174. Api.JetOpenDatabase(this.sesid, null, null, out dbid, OpenDatabaseGrbit.None);
  175. }
  176. /// <summary>
  177. /// Check that an exception is thrown when JetGrowDatabase gets
  178. /// a negative page count.
  179. /// </summary>
  180. [TestMethod]
  181. [Priority(0)]
  182. [ExpectedException(typeof(ArgumentOutOfRangeException))]
  183. [Description("Check that an exception is thrown when JetGrowDatabase a negative page count")]
  184. public void VerifyJetGrowDatabaseThrowsExceptionWhenDesiredPagesIsNegative()
  185. {
  186. int ignored;
  187. Api.JetGrowDatabase(JET_SESID.Nil, JET_DBID.Nil, -1, out ignored);
  188. }
  189. /// <summary>
  190. /// Check that an exception is thrown when JetSetDatabaseSize gets a
  191. /// null database name.
  192. /// </summary>
  193. [TestMethod]
  194. [Priority(0)]
  195. [ExpectedException(typeof(ArgumentNullException))]
  196. [Description("Check that an exception is thrown when JetSetDatabaseSize gets null database name")]
  197. public void JetSetDatabaseSizeThrowsExceptionWhenDatabaseNameIsNull()
  198. {
  199. int ignored;
  200. Api.JetSetDatabaseSize(this.sesid, null, 0, out ignored);
  201. }
  202. /// <summary>
  203. /// Check that an exception is thrown when JetSetDatabaseSize gets
  204. /// a negative page count.
  205. /// </summary>
  206. [TestMethod]
  207. [Priority(0)]
  208. [ExpectedException(typeof(ArgumentOutOfRangeException))]
  209. [Description("Check that an exception is thrown when JetSetDatabaseSize a negative page count")]
  210. public void VerifyJetSetDatabaseSizeThrowsExceptionWhenDesiredPagesIsNegative()
  211. {
  212. int ignored;
  213. Api.JetSetDatabaseSize(this.sesid, "foo.edb", -1, out ignored);
  214. }
  215. /// <summary>
  216. /// JetCompact should throw an exception when
  217. /// the source database is null.
  218. /// </summary>
  219. [TestMethod]
  220. [Priority(0)]
  221. [Description("JetCompact should throw an exception when the source database is null")]
  222. [ExpectedException(typeof(ArgumentNullException))]
  223. public void TestJetCompactThrowsExceptionWhenSourceIsNull()
  224. {
  225. Api.JetCompact(this.sesid, null, "destination", null, null, CompactGrbit.None);
  226. }
  227. /// <summary>
  228. /// JetCompact should throw an exception when
  229. /// the source database is null.
  230. /// </summary>
  231. [TestMethod]
  232. [Priority(0)]
  233. [Description("JetCompact should throw an exception when the source database is null")]
  234. [ExpectedException(typeof(ArgumentNullException))]
  235. public void TestJetCompactThrowsExceptionWhenDestinationIsNull()
  236. {
  237. Api.JetCompact(this.sesid, "source", null, null, null, CompactGrbit.None);
  238. }
  239. /// <summary>
  240. /// JetCompact should throw an exception when
  241. /// the ignored parameter is non-null.
  242. /// </summary>
  243. [TestMethod]
  244. [Priority(0)]
  245. [Description("JetCompact should throw an exception when the ignored parameter is non-null")]
  246. [ExpectedException(typeof(ArgumentException))]
  247. public void TestJetCompactThrowsExceptionWhenIgnoredIsNonNull()
  248. {
  249. #pragma warning disable 618,612 // JET_CONVERT is obsolete
  250. Api.JetCompact(this.sesid, "source", "destination", null, new Converter(), CompactGrbit.None);
  251. #pragma warning restore 618,612
  252. }
  253. #endregion Database API
  254. #region Streaming Backup/Restore
  255. /// <summary>
  256. /// Check that an exception is thrown when JetOpenFileInstance gets a
  257. /// null file name.
  258. /// </summary>
  259. [TestMethod]
  260. [Priority(0)]
  261. [ExpectedException(typeof(ArgumentNullException))]
  262. [Description("Check that an exception is thrown when JetOpenFileInstance gets a null file name")]
  263. public void JetOpenFileInstanceThrowsExceptionWhenFileNameIsNull()
  264. {
  265. JET_HANDLE handle;
  266. long fileSizeLow;
  267. long fileSizeHigh;
  268. Api.JetOpenFileInstance(this.instance, null, out handle, out fileSizeLow, out fileSizeHigh);
  269. }
  270. /// <summary>
  271. /// Check that an exception is thrown when JetReadFileInstance gets a
  272. /// null buffer.
  273. /// </summary>
  274. [TestMethod]
  275. [Priority(0)]
  276. [ExpectedException(typeof(ArgumentNullException))]
  277. [Description("Check that an exception is thrown when JetReadFileInstance gets a null buffer")]
  278. public void JetReadFileInstanceThrowsExceptionWhenBufferIsNull()
  279. {
  280. int bytesRead;
  281. Api.JetReadFileInstance(this.instance, JET_HANDLE.Nil, null, 0, out bytesRead);
  282. }
  283. /// <summary>
  284. /// Check that an exception is thrown when JetReadFileInstance gets a
  285. /// negative buffer size.
  286. /// </summary>
  287. [TestMethod]
  288. [Priority(0)]
  289. [ExpectedException(typeof(ArgumentOutOfRangeException))]
  290. [Description("Check that an exception is thrown when JetReadFileInstance gets a negative buffer size")]
  291. public void JetReadFileInstanceThrowsExceptionWhenBufferSizeIsNegative()
  292. {
  293. int bytesRead;
  294. Api.JetReadFileInstance(this.instance, JET_HANDLE.Nil, new byte[1], -1, out bytesRead);
  295. }
  296. /// <summary>
  297. /// Check that an exception is thrown when JetReadFileInstance gets a
  298. /// buffer size that is too long.
  299. /// </summary>
  300. [TestMethod]
  301. [Priority(0)]
  302. [ExpectedException(typeof(ArgumentOutOfRangeException))]
  303. [Description("Check that an exception is thrown when JetReadFileInstance gets a buffer size that is too long")]
  304. public void JetReadFileInstanceThrowsExceptionWhenBufferSizeIsTooLong()
  305. {
  306. int bytesRead;
  307. Api.JetReadFileInstance(this.instance, JET_HANDLE.Nil, new byte[1], 2, out bytesRead);
  308. }
  309. /// <summary>
  310. /// Check that an exception is thrown when JetGetAttachInfoInstance gets a buffer size that is negative.
  311. /// </summary>
  312. [TestMethod]
  313. [Priority(0)]
  314. [ExpectedException(typeof(ArgumentOutOfRangeException))]
  315. [Description("Check that an exception is thrown when JetGetAttachInfoInstance gets a buffer size that is negative")]
  316. public void JetGetAttachInfoInstanceThrowsExceptionWhenMaxCharsIsNegative()
  317. {
  318. string ignored;
  319. int ignored2;
  320. Api.JetGetAttachInfoInstance(this.instance, out ignored, -1, out ignored2);
  321. }
  322. /// <summary>
  323. /// Check that an exception is thrown when JetGetAttachInfoInstance gets a
  324. /// too large max param value.
  325. /// </summary>
  326. [TestMethod]
  327. [Priority(0)]
  328. [ExpectedException(typeof(OverflowException))]
  329. [Description("Check that an exception is thrown when JetGetAttachInfoInstance gets a too large max param value")]
  330. public void JetGetAttachInfoInstanceThrowsExceptionWhenMaxParamIsTooBig()
  331. {
  332. // This test only fails with the Unicode API (the overflow happens when we try
  333. // to multiply maxParam by sizeof(char))
  334. if (!EsentVersion.SupportsUnicodePaths)
  335. {
  336. throw new OverflowException();
  337. }
  338. string ignored;
  339. int ignored2;
  340. Api.JetGetAttachInfoInstance(this.instance, out ignored, Int32.MaxValue, out ignored2);
  341. }
  342. /// <summary>
  343. /// Check that an exception is thrown when JetGetLogInfoInstance gets a buffer size that is negative.
  344. /// </summary>
  345. [TestMethod]
  346. [Priority(0)]
  347. [ExpectedException(typeof(ArgumentOutOfRangeException))]
  348. [Description("Check that an exception is thrown when JetGetLogInfoInstance gets a buffer size that is negative")]
  349. public void JetGetLogInfoInstanceThrowsExceptionWhenMaxCharsIsNegative()
  350. {
  351. string ignored;
  352. int ignored2;
  353. Api.JetGetLogInfoInstance(this.instance, out ignored, -1, out ignored2);
  354. }
  355. /// <summary>
  356. /// Check that an exception is thrown when JetGetLogInfoInstance gets a
  357. /// too large max param value.
  358. /// </summary>
  359. [TestMethod]
  360. [Priority(0)]
  361. [ExpectedException(typeof(OverflowException))]
  362. [Description("Check that an exception is thrown when JetGetLogInfoInstance gets a too large max param value")]
  363. public void JetGetLogInfoInstanceThrowsExceptionWhenMaxParamIsTooBig()
  364. {
  365. // This test only fails with the Unicode API (the overflow happens when we try
  366. // to multiply maxParam by sizeof(char))
  367. if (!EsentVersion.SupportsUnicodePaths)
  368. {
  369. throw new OverflowException();
  370. }
  371. string ignored;
  372. int ignored2;
  373. Api.JetGetLogInfoInstance(this.instance, out ignored, Int32.MaxValue, out ignored2);
  374. }
  375. /// <summary>
  376. /// Check that an exception is thrown when JetGetTruncateLogInfoInstance gets a buffer size that is negative.
  377. /// </summary>
  378. [TestMethod]
  379. [Priority(0)]
  380. [ExpectedException(typeof(ArgumentOutOfRangeException))]
  381. [Description("Check that an exception is thrown when JetGetTruncateLogInfoInstance gets a buffer size that is negative")]
  382. public void JetGetTruncateLogInfoInstanceThrowsExceptionWhenMaxCharsIsNegative()
  383. {
  384. string ignored;
  385. int ignored2;
  386. Api.JetGetTruncateLogInfoInstance(this.instance, out ignored, -1, out ignored2);
  387. }
  388. /// <summary>
  389. /// Check that an exception is thrown when JetGetTruncateLogInfoInstance gets a
  390. /// too large max param value.
  391. /// </summary>
  392. [TestMethod]
  393. [Priority(0)]
  394. [ExpectedException(typeof(OverflowException))]
  395. [Description("Check that an exception is thrown when JetGetTruncateLogInfoInstance gets a too large max param value")]
  396. public void JetGetTruncateLogInfoInstanceThrowsExceptionWhenMaxParamIsTooBig()
  397. {
  398. // This test only fails with the Unicode API (the overflow happens when we try
  399. // to multiply maxParam by sizeof(char))
  400. if (!EsentVersion.SupportsUnicodePaths)
  401. {
  402. throw new OverflowException();
  403. }
  404. string ignored;
  405. int ignored2;
  406. Api.JetGetTruncateLogInfoInstance(this.instance, out ignored, Int32.MaxValue, out ignored2);
  407. }
  408. #endregion
  409. #region DDL
  410. /// <summary>
  411. /// Check that an exception is thrown when JetOpenTable gets a
  412. /// null table name.
  413. /// </summary>
  414. [TestMethod]
  415. [Priority(0)]
  416. [Description("Check that an exception is thrown when JetOpenTable gets a null table name")]
  417. [ExpectedException(typeof(ArgumentNullException))]
  418. public void JetOpenTableThrowsExceptionWhenTableNameIsNull()
  419. {
  420. JET_TABLEID ignoredTableid;
  421. Api.JetOpenTable(this.sesid, this.dbid, null, null, 0, OpenTableGrbit.None, out ignoredTableid);
  422. }
  423. /// <summary>
  424. /// Check that an exception is thrown when JetOpenTable gets a
  425. /// parameters size that is too long.
  426. /// </summary>
  427. [TestMethod]
  428. [Priority(0)]
  429. [Description("Check that an exception is thrown when JetOpenTable gets a parameters size that is too long")]
  430. [ExpectedException(typeof(ArgumentOutOfRangeException))]
  431. public void JetOpenTableThrowsExceptionWhenParametersSizeIsTooLong()
  432. {
  433. byte[] parameters = new byte[1];
  434. JET_TABLEID ignoredTableid;
  435. Api.JetOpenTable(this.sesid, this.dbid, "table", parameters, parameters.Length + 1, OpenTableGrbit.None, out ignoredTableid);
  436. }
  437. /// <summary>
  438. /// Check that an exception is thrown when JetCreateTable gets a
  439. /// null table name.
  440. /// </summary>
  441. [TestMethod]
  442. [Priority(0)]
  443. [Description("Check that an exception is thrown when JetCreateTable gets a null table name")]
  444. [ExpectedException(typeof(ArgumentNullException))]
  445. public void JetCreateTableThrowsExceptionWhenTableNameIsNull()
  446. {
  447. JET_TABLEID ignoredTableid;
  448. Api.JetCreateTable(this.sesid, this.dbid, null, 0, 100, out ignoredTableid);
  449. }
  450. /// <summary>
  451. /// Check that an exception is thrown when JetDeleteTable gets a
  452. /// null table name.
  453. /// </summary>
  454. [TestMethod]
  455. [Priority(0)]
  456. [Description("Check that an exception is thrown when JetDeleteTable gets a null table name")]
  457. [ExpectedException(typeof(ArgumentNullException))]
  458. public void JetDeleteTableThrowsExceptionWhenTableNameIsNull()
  459. {
  460. Api.JetDeleteTable(this.sesid, this.dbid, null);
  461. }
  462. /// <summary>
  463. /// Check that an exception is thrown when JetGetTableInfo gets a
  464. /// null result buffer.
  465. /// </summary>
  466. [TestMethod]
  467. [Priority(0)]
  468. [Description("Check that an exception is thrown when JetGetTableInfo gets a null result buffer")]
  469. [ExpectedException(typeof(ArgumentNullException))]
  470. public void JetGetTableInfoThrowsExceptionWhenResultIsNull()
  471. {
  472. Api.JetGetTableInfo(this.sesid, this.tableid, null, JET_TblInfo.SpaceUsage);
  473. }
  474. /// <summary>
  475. /// Check that an exception is thrown when JetGetColumnInfo gets a
  476. /// null table name.
  477. /// </summary>
  478. [TestMethod]
  479. [Priority(0)]
  480. [Description("Check that an exception is thrown when JetGetColumnInfo gets a null table name")]
  481. [ExpectedException(typeof(ArgumentNullException))]
  482. public void JetGetColumnInfoThrowsExceptionWhenTableNameIsNull()
  483. {
  484. JET_COLUMNDEF columndef;
  485. Api.JetGetColumnInfo(this.sesid, this.dbid, null, "column", out columndef);
  486. }
  487. /// <summary>
  488. /// Check that an exception is thrown when JetGetColumnInfo gets a
  489. /// null column name.
  490. /// </summary>
  491. [TestMethod]
  492. [Priority(0)]
  493. [Description("Check that an exception is thrown when JetGetColumnInfo gets a null column name")]
  494. [ExpectedException(typeof(ArgumentNullException))]
  495. public void JetGetColumnInfoThrowsExceptionWhenColumnNameIsNull()
  496. {
  497. JET_COLUMNDEF columndef;
  498. Api.JetGetColumnInfo(this.sesid, this.dbid, "table", null, out columndef);
  499. }
  500. /// <summary>
  501. /// Check that an exception is thrown when JetGetColumnInfo gets a
  502. /// null table name.
  503. /// </summary>
  504. /// <remarks>
  505. /// This tests the version of the API that takes a JET_COLUMNLIST.
  506. /// </remarks>
  507. [TestMethod]
  508. [Priority(0)]
  509. [Description("Check that an exception is thrown when JetGetColumnInfo gets a null table name")]
  510. [ExpectedException(typeof(ArgumentNullException))]
  511. public void JetGetColumnInfoThrowsExceptionWhenTableNameIsNull2()
  512. {
  513. JET_COLUMNLIST columnlist;
  514. Api.JetGetColumnInfo(this.sesid, this.dbid, null, null, out columnlist);
  515. }
  516. /// <summary>
  517. /// Check that an exception is thrown when JetGetColumnInfo gets a
  518. /// null table name.
  519. /// </summary>
  520. /// <remarks>
  521. /// This tests the version of the API that takes a JET_COLUMNBASE.
  522. /// </remarks>
  523. [TestMethod]
  524. [Priority(0)]
  525. [Description("Check that an exception is thrown when JetGetColumnInfo gets a null table name")]
  526. [ExpectedException(typeof(ArgumentNullException))]
  527. public void JetGetColumnInfoThrowsExceptionWhenTableNameIsNull3()
  528. {
  529. JET_COLUMNBASE columnbase;
  530. Api.JetGetColumnInfo(this.sesid, this.dbid, null, null, out columnbase);
  531. }
  532. /// <summary>
  533. /// Check that an exception is thrown when JetGetTableColumnInfo gets a
  534. /// null column name.
  535. /// </summary>
  536. [TestMethod]
  537. [Priority(0)]
  538. [Description("Check that an exception is thrown when JetGetTableColumnInfo gets a null column name")]
  539. [ExpectedException(typeof(ArgumentNullException))]
  540. public void JetGetTableColumnInfoThrowsExceptionWhenColumnNameIsNull()
  541. {
  542. JET_COLUMNDEF columndef;
  543. Api.JetGetTableColumnInfo(this.sesid, this.tableid, null, out columndef);
  544. }
  545. /// <summary>
  546. /// Check that an exception is thrown when JetGetIndexInfo gets a
  547. /// null table name.
  548. /// </summary>
  549. [TestMethod]
  550. [Priority(0)]
  551. [Description("Check that an exception is thrown when JetGetIndexInfo(obsolete) gets a null table name")]
  552. [ExpectedException(typeof(ArgumentNullException))]
  553. public void JetGetIndexInfoObsoleteThrowsExceptionWhenTableNameIsNull()
  554. {
  555. JET_INDEXLIST indexlist;
  556. #pragma warning disable 612,618 // Obsolete
  557. Api.JetGetIndexInfo(this.sesid, this.dbid, null, String.Empty, out indexlist);
  558. #pragma warning restore 612,618
  559. }
  560. /// <summary>
  561. /// Check that an exception is thrown when JetGetIndexInfo gets a
  562. /// null table name.
  563. /// </summary>
  564. [TestMethod]
  565. [Priority(0)]
  566. [Description("Check that an exception is thrown when JetGetIndexInfo(ushort) gets a null table name")]
  567. [ExpectedException(typeof(ArgumentNullException))]
  568. public void JetGetIndexInfoUshortThrowsExceptionWhenTableNameIsNull()
  569. {
  570. ushort result;
  571. Api.JetGetIndexInfo(this.sesid, this.dbid, null, String.Empty, out result, JET_IdxInfo.Default);
  572. }
  573. /// <summary>
  574. /// Check that an exception is thrown when JetGetIndexInfo gets a
  575. /// null table name.
  576. /// </summary>
  577. [TestMethod]
  578. [Priority(0)]
  579. [Description("Check that an exception is thrown when JetGetIndexInfo(int) gets a null table name")]
  580. [ExpectedException(typeof(ArgumentNullException))]
  581. public void JetGetIndexInfoIntThrowsExceptionWhenTableNameIsNull()
  582. {
  583. int result;
  584. Api.JetGetIndexInfo(this.sesid, this.dbid, null, String.Empty, out result, JET_IdxInfo.Default);
  585. }
  586. /// <summary>
  587. /// Check that an exception is thrown when JetGetIndexInfo gets a
  588. /// null table name.
  589. /// </summary>
  590. [TestMethod]
  591. [Priority(0)]
  592. [Description("Check that an exception is thrown when JetGetIndexInfo(JET_INDEXID) gets a null table name")]
  593. [ExpectedException(typeof(ArgumentNullException))]
  594. public void JetGetIndexInfoIndexidThrowsExceptionWhenTableNameIsNull()
  595. {
  596. JET_INDEXID result;
  597. Api.JetGetIndexInfo(this.sesid, this.dbid, null, String.Empty, out result, JET_IdxInfo.Default);
  598. }
  599. /// <summary>
  600. /// Check that an exception is thrown when JetGetIndexInfo gets a
  601. /// null table name.
  602. /// </summary>
  603. [TestMethod]
  604. [Priority(0)]
  605. [Description("Check that an exception is thrown when JetGetIndexInfo(JET_INDEXLIST) gets a null table name")]
  606. [ExpectedException(typeof(ArgumentNullException))]
  607. public void JetGetIndexInfoIndexListThrowsExceptionWhenTableNameIsNull()
  608. {
  609. JET_INDEXLIST result;
  610. Api.JetGetIndexInfo(this.sesid, this.dbid, null, String.Empty, out result, JET_IdxInfo.Default);
  611. }
  612. /// <summary>
  613. /// Check that an exception is thrown when JetRenameTable gets a
  614. /// null table name.
  615. /// </summary>
  616. [TestMethod]
  617. [Priority(0)]
  618. [Description("Check that an exception is thrown when JetRenameTable gets a null table name")]
  619. [ExpectedException(typeof(ArgumentNullException))]
  620. public void JetRenameTableThrowsExceptionWhenTableNameIsNull()
  621. {
  622. Api.JetRenameTable(this.sesid, this.dbid, null, "newtable");
  623. }
  624. /// <summary>
  625. /// Check that an exception is thrown when JetRenameTable gets a
  626. /// null new table name.
  627. /// </summary>
  628. [TestMethod]
  629. [Priority(0)]
  630. [Description("Check that an exception is thrown when JetRenameTable gets a null new table name")]
  631. [ExpectedException(typeof(ArgumentNullException))]
  632. public void JetRenameTableThrowsExceptionWhenNewTableNameIsNull()
  633. {
  634. Api.JetRenameTable(this.sesid, this.dbid, "oldtable", null);
  635. }
  636. /// <summary>
  637. /// Verify that an exception is thrown when JetRenameColumn gets a
  638. /// null column name.
  639. /// </summary>
  640. [TestMethod]
  641. [Priority(0)]
  642. [Description("Verify that an exception is thrown when JetRenameColumn gets a null column name")]
  643. [ExpectedException(typeof(ArgumentNullException))]
  644. public void VerifyJetRenameColumnThrowsExceptionWhencolumnNameIsNull()
  645. {
  646. Api.JetRenameColumn(this.sesid, this.tableid, null, "newcolumn", RenameColumnGrbit.None);
  647. }
  648. /// <summary>
  649. /// Verify that an exception is thrown when JetRenameColumn gets a
  650. /// null new column name.
  651. /// </summary>
  652. [TestMethod]
  653. [Priority(0)]
  654. [Description("Verify that an exception is thrown when JetRenameColumn gets a null new column name")]
  655. [ExpectedException(typeof(ArgumentNullException))]
  656. public void VerifyJetRenameColumnThrowsExceptionWhenNewColumnNameIsNull()
  657. {
  658. Api.JetRenameColumn(this.sesid, this.tableid, "oldcolumn", null, RenameColumnGrbit.None);
  659. }
  660. /// <summary>
  661. /// Verify that an exception is thrown when JetSetColumnDefaultValue gets a null table name.
  662. /// </summary>
  663. [TestMethod]
  664. [Priority(0)]
  665. [Description(" Verify that an exception is thrown when JetSetColumnDefaultValue gets a null table name")]
  666. [ExpectedException(typeof(ArgumentNullException))]
  667. public void VerifyJetSetColumnDefaultValueThrowsExceptionWhenTableNameIsNull()
  668. {
  669. Api.JetSetColumnDefaultValue(this.sesid, this.dbid, null, "column", new byte[1], 1, SetColumnDefaultValueGrbit.None);
  670. }
  671. /// <summary>
  672. /// Verify that an exception is thrown when JetSetColumnDefaultValue gets a null column name.
  673. /// </summary>
  674. [TestMethod]
  675. [Priority(0)]
  676. [Description(" Verify that an exception is thrown when JetSetColumnDefaultValue gets a null column name")]
  677. [ExpectedException(typeof(ArgumentNullException))]
  678. public void VerifyJetSetColumnDefaultValueThrowsExceptionWhenColumnNameIsNull()
  679. {
  680. Api.JetSetColumnDefaultValue(this.sesid, this.dbid, "table", null, new byte[1], 1, SetColumnDefaultValueGrbit.None);
  681. }
  682. /// <summary>
  683. /// Verify that an exception is thrown when JetSetColumnDefaultValue gets a negative data size.
  684. /// </summary>
  685. [TestMethod]
  686. [Priority(0)]
  687. [Description("Verify that an exception is thrown when JetSetColumnDefaultValue gets a negative data size")]
  688. [ExpectedException(typeof(ArgumentOutOfRangeException))]
  689. public void VerifyJetSetColumnDefaultValueThrowsExceptionWhenDataSizeIsNegative()
  690. {
  691. Api.JetSetColumnDefaultValue(this.sesid, this.dbid, "table", "column", null, -1, SetColumnDefaultValueGrbit.None);
  692. }
  693. /// <summary>
  694. /// Verify that an exception is thrown when JetSetColumnDefaultValue gets a data size that is too long.
  695. /// </summary>
  696. [TestMethod]
  697. [Priority(0)]
  698. [Description("Verify that an exception is thrown when JetSetColumnDefaultValue gets a data size that is too long")]
  699. [ExpectedException(typeof(ArgumentOutOfRangeException))]
  700. public void VerifyJetSetColumnDefaultValueThrowsExceptionWhenDataSizeIsTooLong()
  701. {
  702. Api.JetSetColumnDefaultValue(this.sesid, this.dbid, "table", "column", new byte[1], 2, SetColumnDefaultValueGrbit.None);
  703. }
  704. /// <summary>
  705. /// Check that an exception is thrown when JetAddColumn gets a
  706. /// null column name.
  707. /// </summary>
  708. [TestMethod]
  709. [Priority(0)]
  710. [Description("Check that an exception is thrown when JetAddColumn gets a null column name")]
  711. [ExpectedException(typeof(ArgumentNullException))]
  712. public void JetAddColumnThrowsExceptionWhenColumnNameIsNull()
  713. {
  714. var columndef = new JET_COLUMNDEF()
  715. {
  716. coltyp = JET_coltyp.Binary,
  717. };
  718. JET_COLUMNID columnid;
  719. Api.JetAddColumn(
  720. this.sesid,
  721. this.tableid,
  722. null,
  723. columndef,
  724. null,
  725. 0,
  726. out columnid);
  727. }
  728. /// <summary>
  729. /// Check that an exception is thrown when JetAddColumn gets a
  730. /// null column definition.
  731. /// </summary>
  732. [TestMethod]
  733. [Priority(0)]
  734. [Description("Check that an exception is thrown when JetAddColumn gets a null column definition")]
  735. [ExpectedException(typeof(ArgumentNullException))]
  736. public void JetAddColumnThrowsExceptionWhenColumndefIsNull()
  737. {
  738. JET_COLUMNID columnid;
  739. Api.JetAddColumn(
  740. this.sesid,
  741. this.tableid,
  742. "column",
  743. null,
  744. null,
  745. 0,
  746. out columnid);
  747. }
  748. /// <summary>
  749. /// Check that an exception is thrown when JetAddColumn gets a
  750. /// default value length that is negative.
  751. /// </summary>
  752. [TestMethod]
  753. [Priority(0)]
  754. [Description("Check that an exception is thrown when JetAddColumn gets a default value length that is negative")]
  755. [ExpectedException(typeof(ArgumentOutOfRangeException))]
  756. public void JetAddColumnThrowsExceptionWhenDefaultValueLengthIsNegative()
  757. {
  758. var columndef = new JET_COLUMNDEF()
  759. {
  760. coltyp = JET_coltyp.Binary,
  761. };
  762. JET_COLUMNID columnid;
  763. Api.JetAddColumn(
  764. this.sesid,
  765. this.tableid,
  766. "NegativeDefaultValue",
  767. columndef,
  768. null,
  769. -1,
  770. out columnid);
  771. }
  772. /// <summary>
  773. /// Check that an exception is thrown when JetAddColumn gets a
  774. /// default value length that is too long.
  775. /// </summary>
  776. [TestMethod]
  777. [Priority(0)]
  778. [Description("Check that an exception is thrown when JetAddColumn gets a default value length that is too long")]
  779. [ExpectedException(typeof(ArgumentOutOfRangeException))]
  780. public void JetAddColumnThrowsExceptionWhenDefaultValueLengthIsTooLong()
  781. {
  782. var defaultValue = new byte[10];
  783. var columndef = new JET_COLUMNDEF()
  784. {
  785. coltyp = JET_coltyp.Binary,
  786. };
  787. JET_COLUMNID columnid;
  788. Api.JetAddColumn(
  789. this.sesid,
  790. this.tableid,
  791. "BadDefaultValue",
  792. columndef,
  793. defaultValue,
  794. defaultValue.Length + 1,
  795. out columnid);
  796. }
  797. /// <summary>
  798. /// Check that an exception is thrown when JetAddColumn gets a
  799. /// default value that is null with a non-zero default value size.
  800. /// </summary>
  801. [TestMethod]
  802. [Priority(0)]
  803. [Description("Check that an exception is thrown when JetAddColumn gets a default value that is null with a non-zero default value size")]
  804. [ExpectedException(typeof(ArgumentOutOfRangeException))]
  805. public void JetAddColumnThrowsExceptionWhenDefaultValueIsUnexpectedNull()
  806. {
  807. var defaultValue = new byte[10];
  808. var columndef = new JET_COLUMNDEF()
  809. {
  810. coltyp = JET_coltyp.Binary,
  811. };
  812. JET_COLUMNID columnid;
  813. Api.JetAddColumn(
  814. this.sesid,
  815. this.tableid,
  816. "BadDefaultValue",
  817. columndef,
  818. null,
  819. 1,
  820. out columnid);
  821. }
  822. /// <summary>
  823. /// Check that an exception is thrown when JetCreateIndex gets a
  824. /// null name.
  825. /// </summary>
  826. [TestMethod]
  827. [Priority(0)]
  828. [Description("Check that an exception is thrown when JetCreateIndex gets a null name")]
  829. [ExpectedException(typeof(ArgumentNullException))]
  830. public void JetCreateIndexThrowsExceptionWhenNameIsNull()
  831. {
  832. Api.JetCreateIndex(this.sesid, this.tableid, null, CreateIndexGrbit.None, "+foo\0", 6, 100);
  833. }
  834. /// <summary>
  835. /// Check that an exception is thrown when JetCreateIndex gets a
  836. /// density that is negative.
  837. /// </summary>
  838. [TestMethod]
  839. [Priority(0)]
  840. [Description("Check that an exception is thrown when JetCreateIndex gets a density that is negative")]
  841. [ExpectedException(typeof(ArgumentOutOfRangeException))]
  842. public void JetCreateIndexThrowsExceptionWhenDensityIsNegative()
  843. {
  844. Api.JetCreateIndex(this.sesid, this.tableid, "BadIndex,", CreateIndexGrbit.None, "+foo\0", 6, -1);
  845. }
  846. /// <summary>
  847. /// Check that an exception is thrown when JetCreateIndex gets a
  848. /// key description length that is negative.
  849. /// </summary>
  850. [TestMethod]
  851. [Priority(0)]
  852. [Description("Check that an exception is thrown when JetCreateIndex gets a key description length that is negative")]
  853. [ExpectedException(typeof(ArgumentOutOfRangeException))]
  854. public void JetCreateIndexThrowsExceptionWhenKeyDescriptionLengthIsNegative()
  855. {
  856. Api.JetCreateIndex(this.sesid, this.tableid, "BadIndex,", CreateIndexGrbit.None, "+foo\0", -1, 100);
  857. }
  858. /// <summary>
  859. /// Check that an exception is thrown when JetCreateIndex gets a
  860. /// key description length that is too long.
  861. /// </summary>
  862. [TestMethod]
  863. [Priority(0)]
  864. [Description("Check that an exception is thrown when JetCreateIndex gets a key description length that is too long")]
  865. [ExpectedException(typeof(ArgumentOutOfRangeException))]
  866. public void JetCreateIndexThrowsExceptionWhenKeyDescriptionLengthIsTooLong()
  867. {
  868. Api.JetCreateIndex(this.sesid, this.tableid, "BadIndex,", CreateIndexGrbit.None, "+foo\0", 77, 100);
  869. }
  870. /// <summary>
  871. /// Check that an exception is thrown when JetCreateIndex2 gets
  872. /// null indexcreates.
  873. /// </summary>
  874. [TestMethod]
  875. [Priority(0)]
  876. [Description("Check that an exception is thrown when JetCreateIndex2 gets null indexcreates")]
  877. [ExpectedException(typeof(ArgumentNullException))]
  878. public void JetCreateIndex2ThrowsExceptionWhenIndexcreatesAreNull()
  879. {
  880. Api.JetCreateIndex2(this.sesid, this.tableid, null, 0);
  881. }
  882. /// <summary>
  883. /// Check that an exception is thrown when JetCreateIndex2 gets
  884. /// a negative indexcreate count.
  885. /// </summary>
  886. [TestMethod]
  887. [Priority(0)]
  888. [Description("Check that an exception is thrown when JetCreateIndex2 gets a negative indexcreate count")]
  889. [ExpectedException(typeof(ArgumentOutOfRangeException))]
  890. public void JetCreateIndex2ThrowsExceptionWhenNumIndexcreatesIsNegative()
  891. {
  892. var indexcreates = new[] { new JET_INDEXCREATE() };
  893. Api.JetCreateIndex2(this.sesid, this.tableid, indexcreates, -1);
  894. }
  895. /// <summary>
  896. /// Check that an exception is thrown when JetCreateIndex2 gets
  897. /// an indexcreate count that is too long.
  898. /// </summary>
  899. [TestMethod]
  900. [Priority(0)]
  901. [Description("Check that an exception is thrown when JetCreateIndex2 gets an indexcreate count that is too long")]
  902. [ExpectedException(typeof(ArgumentOutOfRangeException))]
  903. public void JetCreateIndex2ThrowsExceptionWhenNumIndexcreatesIsTooLong()
  904. {
  905. var indexcreates = new[] { new JET_INDEXCREATE() };
  906. Api.JetCreateIndex2(this.sesid, this.tableid, indexcreates, indexcreates.Length + 1);
  907. }
  908. /// <summary>
  909. /// Check that an exception is thrown when JetCreateIndex2 gets a
  910. /// null index name.
  911. /// </summary>
  912. [TestMethod]
  913. [Priority(0)]
  914. [Description("Check that an exception is thrown when JetCreateIndex2 gets a null index name")]
  915. [ExpectedException(typeof(ArgumentNullException))]
  916. public void JetCreateIndex2ThrowsExceptionWhenIndexNameIsNull()
  917. {
  918. const string Key = "+column\0";
  919. var indexcreates = new[]
  920. {
  921. new JET_INDEXCREATE
  922. {
  923. cbKey = Key.Length,
  924. szKey = Key,
  925. },
  926. };
  927. Api.JetCreateIndex2(this.sesid, this.tableid, indexcreates, indexcreates.Length);
  928. }
  929. /// <summary>
  930. /// Check that an exception is thrown when JetDeleteColumn gets a
  931. /// null column name.
  932. /// </summary>
  933. [TestMethod]
  934. [Priority(0)]
  935. [Description("Check that an exception is thrown when JetDeleteColumn gets a null column name")]
  936. [ExpectedException(typeof(ArgumentNullException))]
  937. public void JetDeleteColumnThrowsExceptionWhenColumnNameIsNull()
  938. {
  939. Api.JetDeleteColumn(this.sesid, this.tableid, null);
  940. }
  941. /// <summary>
  942. /// Check that an exception is thrown when JetDeleteColumn gets a
  943. /// null column name.
  944. /// </summary>
  945. [TestMethod]
  946. [Priority(0)]
  947. [Description("Check that an exception is thrown when JetDeleteColumn gets a null column name")]
  948. [ExpectedException(typeof(ArgumentNullException))]
  949. public void JetDeleteColumn2ThrowsExceptionWhenColumnNameIsNull()
  950. {
  951. Api.JetDeleteColumn2(this.sesid, this.tableid, null, DeleteColumnGrbit.None);
  952. }
  953. /// <summary>
  954. /// Check that an exception is thrown when JetDeleteIndex gets a
  955. /// null index name.
  956. /// </summary>
  957. [TestMethod]
  958. [Priority(0)]
  959. [Description("Check that an exception is thrown when JetDeleteIndex gets a null index name")]
  960. [ExpectedException(typeof(ArgumentNullException))]
  961. public void JetDeleteIndexThrowsExceptionWhenIndexNameIsNull()
  962. {
  963. Api.JetDeleteIndex(this.sesid, this.tableid, null);
  964. }
  965. #endregion
  966. #region Meta-data Helpers
  967. /// <summary>
  968. /// Verify that an exception is thrown when TryOpenTable gets a null table name.
  969. /// </summary>
  970. [TestMethod]
  971. [Priority(0)]
  972. [Description("Verify that an exception is thrown when TryOpenTable gets a null table name")]
  973. [ExpectedException(typeof(ArgumentNullException))]
  974. public void VerifyTryOpenTableThrowsExceptionWhenTableNameIsNull()
  975. {
  976. JET_TABLEID t;
  977. Api.TryOpenTable(this.sesid, this.dbid, null, OpenTableGrbit.None, out t);
  978. }
  979. /// <summary>
  980. /// Verify that an exception is thrown when GetTableColumnid gets a null column name.
  981. /// </summary>
  982. [TestMethod]
  983. [Priority(0)]
  984. [Description("Verify that an exception is thrown when GetTableColumnid gets a null column name")]
  985. [ExpectedException(typeof(ArgumentNullException))]
  986. public void VerifyGetTableColumnidThrowsExceptionWhenColumnNameIsNull()
  987. {
  988. Api.GetTableColumnid(this.sesid, this.tableid, null);
  989. }
  990. /// <summary>
  991. /// Verify that an exception is thrown when GetTableColumns gets a null table name.
  992. /// </summary>
  993. [TestMethod]
  994. [Priority(0)]
  995. [Description("Verify that an exception is thrown when GetTableColumns gets a null table name")]
  996. [ExpectedException(typeof(ArgumentNullException))]
  997. public void VerifyGetTableColumnsThrowsExceptionWhenTableNameIsNull()
  998. {
  999. Api.GetTableColumns(this.sesid, this.dbid, null);
  1000. }
  1001. /// <summary>
  1002. /// Verify that an exception is thrown when GetTableIndexes gets a null table name.
  1003. /// </summary>
  1004. [TestMethod]
  1005. [Priority(0)]
  1006. [Description("Verify that an exception is thrown when GetTableIndexes gets a null table name")]
  1007. [ExpectedException(typeof(ArgumentNullException))]
  1008. public void VerifyGetTableIndexesThrowsExceptionWhenTableNameIsNull()
  1009. {
  1010. Api.GetTableIndexes(this.sesid, this.dbid, null);
  1011. }
  1012. #endregion
  1013. #region Temporary Table Creation
  1014. /// <summary>
  1015. /// Null columns is invalid.
  1016. /// </summary>
  1017. [TestMethod]
  1018. [Priority(0)]
  1019. [Description("Verify JetOpenTempTable throws an Exception when columns parameter is null")]
  1020. [ExpectedException(typeof(ArgumentNullException))]
  1021. public void VerifyJetOpenTempTableThrowsExceptionWhenColumnsIsNull()
  1022. {
  1023. JET_TABLEID tableidIgnored;
  1024. var columnids = new JET_COLUMNID[1];
  1025. Api.JetOpenTempTable(this.sesid, null, 0, TempTableGrbit.None, out tableidIgnored, columnids);
  1026. }
  1027. /// <summary>
  1028. /// Null columnids is invalid.
  1029. /// </summary>
  1030. [TestMethod]
  1031. [Priority(0)]
  1032. [ExpectedException(typeof(ArgumentNullException))]
  1033. [Description("Verify JetOpenTempTable throws an Exception when columnids parameter is null")]
  1034. public void VerifyJetOpenTempTableThrowsExceptionWhenColumnidsIsNull()
  1035. {
  1036. JET_TABLEID tableidIgnored;
  1037. var columns = new[] { new JET_COLUMNDEF() };
  1038. Api.JetOpenTempTable(this.sesid, columns, columns.Length, TempTableGrbit.None, out tableidIgnored, null);
  1039. }
  1040. /// <summary>
  1041. /// Columnids must match columndefs in length.
  1042. /// </summary>
  1043. [TestMethod]
  1044. [Priority(0)]
  1045. [ExpectedException(typeof(ArgumentOutOfRangeException))]
  1046. [Description("Verify JetOpenTempTable throws an Exception when columnids parameter is the wrong length")]
  1047. public void VerifyJetOpenTempTableThrowsExceptionWhenColumnidsIsTooShort()
  1048. {
  1049. JET_TABLEID tableidIgnored;
  1050. var columns = new[] { new JET_COLUMNDEF(), new JET_COLUMNDEF() };
  1051. var columnids = new JET_COLUMNID[columns.Length - 1];
  1052. Api.JetOpenTempTable(this.sesid, columns, columns.Length, TempTableGrbit.None, out tableidIgnored, columnids);
  1053. }
  1054. /// <summary>
  1055. /// Negative column count is invalid.
  1056. /// </summary>
  1057. [TestMethod]
  1058. [Priority(0)]
  1059. [ExpectedException(typeof(ArgumentOutOfRangeException))]
  1060. [Description("Verify JetOpenTempTable throws an Exception when column count is negative")]
  1061. public void VerifyJetOpenTempTableThrowsExceptionWhenColumnCountIsNegative()
  1062. {
  1063. JET_TABLEID tableidIgnored;
  1064. var columns = new[] { new JET_COLUMNDEF() };
  1065. var columnids = new JET_COLUMNID[1];
  1066. Api.JetOpenTempTable(this.sesid, columns, -1, TempTableGrbit.None, out tableidIgnored, columnids);
  1067. }
  1068. /// <summary>
  1069. /// Too-long column count is invalid.
  1070. /// </summary>
  1071. [TestMethod]
  1072. [Priority(0)]
  1073. [Description("Verify JetOpenTempTable throws an Exception when column count is too long")]
  1074. [ExpectedException(typeof(ArgumentOutOfRangeException))]
  1075. public void VerifyJetOpenTempTableThrowsExceptionWhenColumnCountIsTooLong()
  1076. {
  1077. JET_TABLEID tableidIgnored;
  1078. var columns = new[] { new JET_COLUMNDEF() };
  1079. var columnids = new JET_COLUMNID[1];
  1080. Api.JetOpenTempTable(this.sesid, columns, 2, TempTableGrbit.None, out tableidIgnored, columnids);
  1081. }
  1082. /// <summary>
  1083. /// Null columns is invalid.
  1084. /// </summary>
  1085. [TestMethod]
  1086. [Priority(0)]
  1087. [Description("Verify JetOpenTempTable2 throws an Exception when columns parameter is null")]
  1088. [ExpectedException(typeof(ArgumentNullException))]
  1089. public void VerifyJetOpenTempTable2ThrowsExceptionWhenColumnsIsNull()
  1090. {
  1091. JET_TABLEID tableidIgnored;
  1092. var columnids = new JET_COLUMNID[1];
  1093. Api.JetOpenTempTable2(this.sesid, null, 0, 1033, TempTableGrbit.None, out tableidIgnored, columnids);
  1094. }
  1095. /// <summary>
  1096. /// Null columnids is invalid.
  1097. /// </summary>
  1098. [TestMethod]