testdbbasics.pas 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464
  1. unit TestDBBasics;
  2. {$IFDEF FPC}
  3. {$mode Delphi}{$H+}
  4. {$ENDIF}
  5. interface
  6. uses
  7. fpcunit, testutils, testregistry, testdecorator,
  8. Classes, SysUtils, db;
  9. type
  10. { TTestDBBasics }
  11. TTestDBBasics = class(TTestCase)
  12. private
  13. procedure TestOnFilterProc(DataSet: TDataSet; var Accept: Boolean);
  14. procedure TestfieldDefinition(AFieldType : TFieldType;ADatasize : integer;var ADS : TDataset; var AFld: TField);
  15. procedure TestcalculatedField_OnCalcfields(DataSet: TDataSet);
  16. procedure FTestDelete1(TestCancelUpdate : boolean);
  17. procedure FTestDelete2(TestCancelUpdate : boolean);
  18. procedure TestAddIndexFieldType(AFieldType : TFieldType; ActiveDS : boolean);
  19. protected
  20. procedure SetUp; override;
  21. procedure TearDown; override;
  22. published
  23. procedure TestCancelUpdDelete1;
  24. procedure TestCancelUpdDelete2;
  25. procedure TestBookmarks;
  26. procedure TestFirst;
  27. procedure TestDelete1;
  28. procedure TestDelete2;
  29. procedure TestIntFilter;
  30. procedure TestOnFilter;
  31. procedure TestStringFilter;
  32. procedure TestAddIndex;
  33. procedure TestInactSwitchIndex;
  34. procedure TestAddIndexInteger;
  35. procedure TestAddIndexSmallInt;
  36. procedure TestAddIndexBoolean;
  37. procedure TestAddIndexFloat;
  38. procedure TestAddIndexLargeInt;
  39. procedure TestAddIndexDateTime;
  40. procedure TestAddIndexCurrency;
  41. procedure TestAddIndexBCD;
  42. procedure TestAddIndexActiveDS;
  43. procedure TestAddIndexEditDS;
  44. procedure TestNullAtOpen;
  45. procedure TestSupportIntegerFields;
  46. procedure TestSupportSmallIntFields;
  47. procedure TestSupportStringFields;
  48. procedure TestSupportBooleanFields;
  49. procedure TestSupportFloatFields;
  50. procedure TestSupportLargeIntFields;
  51. procedure TestSupportDateFields;
  52. procedure TestSupportCurrencyFields;
  53. procedure TestSupportBCDFields;
  54. procedure TestIsEmpty;
  55. procedure TestAppendOnEmptyDataset;
  56. procedure TestInsertOnEmptyDataset;
  57. procedure TestBufDatasetCancelUpd; //bug 6938
  58. procedure TestEofAfterFirst; //bug 7211
  59. procedure TestBufDatasetCancelUpd1;
  60. procedure TestDoubleClose;
  61. procedure TestCalculatedField;
  62. procedure TestAssignFieldftString;
  63. procedure TestAssignFieldftFixedChar;
  64. procedure TestSelectQueryBasics;
  65. procedure TestPostOnlyInEditState;
  66. procedure TestMove; // bug 5048
  67. procedure TestActiveBufferWhenClosed;
  68. procedure TestEOFBOFClosedDataset;
  69. procedure TestDataEventsResync;
  70. procedure TestBug7007;
  71. procedure TestBug6893;
  72. procedure TestRecordcountAfterReopen; // partly bug 8228
  73. procedure TestdeFieldListChange;
  74. procedure TestLastAppendCancel; // bug 5058
  75. procedure TestRecNo; // bug 5061
  76. procedure TestSetRecNo; // bug 6919
  77. procedure TestRequired;
  78. end;
  79. { TSQLTestSetup }
  80. TDBBasicsTestSetup = class(TTestSetup)
  81. protected
  82. procedure OneTimeSetup; override;
  83. procedure OneTimeTearDown; override;
  84. end;
  85. implementation
  86. uses toolsunit, bufdataset;
  87. type THackDataLink=class(TdataLink);
  88. procedure TTestDBBasics.TestIsEmpty;
  89. begin
  90. if not (DBConnector.GetNDataset(5) is TBufDataset) then
  91. Ignore('This test only applies to TBufDataset and descendents.');
  92. with tbufdataset(DBConnector.GetNDataset(True,1)) do
  93. begin
  94. open;
  95. delete;
  96. refresh;
  97. applyupdates;
  98. AssertTrue(IsEmpty);
  99. end;
  100. end;
  101. procedure TTestDBBasics.TestAppendOnEmptyDataset;
  102. begin
  103. with DBConnector.GetNDataset(0) do
  104. begin
  105. open;
  106. AssertTrue(CanModify);
  107. AssertTrue(eof);
  108. AssertTrue(bof);
  109. append;
  110. AssertFalse(Bof);
  111. AssertTrue(Eof);
  112. post;
  113. AssertFalse(eof);
  114. AssertFalse(bof);
  115. end;
  116. end;
  117. procedure TTestDBBasics.TestInsertOnEmptyDataset;
  118. begin
  119. with DBConnector.GetNDataset(0) do
  120. begin
  121. open;
  122. AssertTrue(CanModify);
  123. AssertTrue(eof);
  124. AssertTrue(bof);
  125. AssertTrue(IsEmpty);
  126. insert;
  127. AssertTrue(Bof);
  128. AssertTrue(Eof);
  129. AssertFalse(IsEmpty);
  130. post;
  131. AssertFalse(IsEmpty);
  132. AssertFalse(eof);
  133. AssertFalse(bof);
  134. end;
  135. end;
  136. procedure TTestDBBasics.TestSelectQueryBasics;
  137. var b : TFieldType;
  138. begin
  139. with DBConnector.GetNDataset(1) do
  140. begin
  141. Open;
  142. AssertEquals(1,RecNo);
  143. AssertEquals(1,RecordCount);
  144. AssertEquals(2,FieldCount);
  145. AssertTrue(CompareText('ID',fields[0].FieldName)=0);
  146. AssertTrue(CompareText('ID',fields[0].DisplayName)=0);
  147. AssertTrue('The datatype of the field ''ID'' is incorrect, it should be ftInteger',ftInteger=fields[0].DataType);
  148. AssertTrue(CompareText('NAME',fields[1].FieldName)=0);
  149. AssertTrue(CompareText('NAME',fields[1].DisplayName)=0);
  150. AssertTrue(ftString=fields[1].DataType);
  151. AssertEquals(1,fields[0].Value);
  152. AssertEquals('TestName1',fields[1].Value);
  153. Close;
  154. end;
  155. end;
  156. procedure TTestDBBasics.TestPostOnlyInEditState;
  157. begin
  158. with DBConnector.GetNDataset(1) do
  159. begin
  160. open;
  161. AssertException('Post was called in a non-edit state',EDatabaseError,Post);
  162. end;
  163. end;
  164. procedure TTestDBBasics.TestMove;
  165. var i,count : integer;
  166. aDatasource : TDataSource;
  167. aDatalink : TDataLink;
  168. ABufferCount : Integer;
  169. begin
  170. aDatasource := TDataSource.Create(nil);
  171. aDatalink := TTestDataLink.Create;
  172. aDatalink.DataSource := aDatasource;
  173. ABufferCount := 11;
  174. aDatalink.BufferCount := ABufferCount;
  175. DataEvents := '';
  176. for count := 0 to 32 do
  177. begin
  178. aDatasource.DataSet := DBConnector.GetNDataset(count);
  179. with aDatasource.Dataset do
  180. begin
  181. i := 1;
  182. Open;
  183. AssertEquals('deUpdateState:0;',DataEvents);
  184. DataEvents := '';
  185. while not EOF do
  186. begin
  187. AssertEquals(i,fields[0].AsInteger);
  188. AssertEquals('TestName'+inttostr(i),fields[1].AsString);
  189. inc(i);
  190. Next;
  191. if (i > ABufferCount) and not EOF then
  192. AssertEquals('deCheckBrowseMode:0;deDataSetScroll:-1;',DataEvents)
  193. else
  194. AssertEquals('deCheckBrowseMode:0;deDataSetScroll:0;',DataEvents);
  195. DataEvents := '';
  196. end;
  197. AssertEquals(count,i-1);
  198. close;
  199. AssertEquals('deUpdateState:0;',DataEvents);
  200. DataEvents := '';
  201. end;
  202. end;
  203. end;
  204. procedure TTestDBBasics.TestdeFieldListChange;
  205. var i,count : integer;
  206. aDatasource : TDataSource;
  207. aDatalink : TDataLink;
  208. ds : TDataset;
  209. begin
  210. aDatasource := TDataSource.Create(nil);
  211. aDatalink := TTestDataLink.Create;
  212. aDatalink.DataSource := aDatasource;
  213. ds := DBConnector.GetNDataset(1);
  214. with ds do
  215. begin
  216. aDatasource.DataSet := ds;
  217. DataEvents := '';
  218. open;
  219. Fields.add(tfield.Create(DBConnector.GetNDataset(1)));
  220. AssertEquals('deUpdateState:0;deFieldListChange:0;',DataEvents);
  221. DataEvents := '';
  222. fields.Clear;
  223. AssertEquals('deFieldListChange:0;',DataEvents)
  224. end;
  225. aDatasource.Free;
  226. aDatalink.Free;
  227. end;
  228. procedure TTestDBBasics.TestActiveBufferWhenClosed;
  229. begin
  230. with DBConnector.GetNDataset(0) do
  231. begin
  232. AssertNull(ActiveBuffer);
  233. open;
  234. AssertFalse('Activebuffer of an empty dataset shouldn''t be nil',ActiveBuffer = nil);
  235. end;
  236. end;
  237. procedure TTestDBBasics.TestEOFBOFClosedDataset;
  238. begin
  239. with DBConnector.GetNDataset(1) do
  240. begin
  241. AssertTrue(EOF);
  242. AssertTrue(BOF);
  243. open;
  244. close;
  245. AssertTrue(EOF);
  246. AssertTrue(BOF);
  247. end;
  248. end;
  249. procedure TTestDBBasics.TestDataEventsResync;
  250. var i,count : integer;
  251. aDatasource : TDataSource;
  252. aDatalink : TDataLink;
  253. ds : tdataset;
  254. begin
  255. aDatasource := TDataSource.Create(nil);
  256. aDatalink := TTestDataLink.Create;
  257. aDatalink.DataSource := aDatasource;
  258. ds := DBConnector.GetNDataset(6);
  259. ds.BeforeScroll := DBConnector.DataEvent;
  260. with ds do
  261. begin
  262. aDatasource.DataSet := ds;
  263. open;
  264. DataEvents := '';
  265. Resync([rmExact]);
  266. AssertEquals('deDataSetChange:0;',DataEvents);
  267. DataEvents := '';
  268. next;
  269. AssertEquals('deCheckBrowseMode:0;DataEvent;deDataSetScroll:0;',DataEvents);
  270. close;
  271. end;
  272. aDatasource.Free;
  273. aDatalink.Free;
  274. end;
  275. procedure TTestDBBasics.TestLastAppendCancel;
  276. var count : integer;
  277. begin
  278. for count := 0 to 32 do with DBConnector.GetNDataset(count) do
  279. begin
  280. open;
  281. Last;
  282. Append;
  283. Cancel;
  284. AssertEquals(count,fields[0].asinteger);
  285. AssertEquals(count,RecordCount);
  286. Close;
  287. end;
  288. end;
  289. procedure TTestDBBasics.TestRecNo;
  290. var i : longint;
  291. passed : boolean;
  292. begin
  293. with DBConnector.GetNDataset(0) do
  294. begin
  295. // Accessing RecNo on a closed dataset should raise an EDatabaseError or should
  296. // return 0
  297. passed := false;
  298. try
  299. i := recno;
  300. except on E: Exception do
  301. begin
  302. passed := E.classname = EDatabaseError.className
  303. end;
  304. end;
  305. if not passed then
  306. AssertEquals('Failed to get the RecNo from a closed dataset',0,RecNo);
  307. // Accessing Recordcount on a closed dataset should raise an EDatabaseError or should
  308. // return 0
  309. passed := false;
  310. try
  311. i := recordcount;
  312. except on E: Exception do
  313. begin
  314. passed := E.classname = EDatabaseError.className
  315. end;
  316. end;
  317. if not passed then
  318. AssertEquals('Failed to get the Recordcount from a closed dataset',0,RecNo);
  319. Open;
  320. AssertEquals(0,RecordCount);
  321. AssertEquals(0,RecNo);
  322. first;
  323. AssertEquals(0,RecordCount);
  324. AssertEquals(0,RecNo);
  325. last;
  326. AssertEquals(0,RecordCount);
  327. AssertEquals(0,RecNo);
  328. append;
  329. AssertEquals(0,RecNo);
  330. AssertEquals(0,RecordCount);
  331. first;
  332. AssertEquals(0,RecNo);
  333. AssertEquals(0,RecordCount);
  334. append;
  335. FieldByName('id').AsInteger := 1;
  336. AssertEquals(0,RecNo);
  337. AssertEquals(0,RecordCount);
  338. first;
  339. AssertEquals(1,RecNo);
  340. AssertEquals(1,RecordCount);
  341. last;
  342. AssertEquals(1,RecNo);
  343. AssertEquals(1,RecordCount);
  344. append;
  345. FieldByName('id').AsInteger := 1;
  346. AssertEquals(0,RecNo);
  347. AssertEquals(1,RecordCount);
  348. Close;
  349. end;
  350. end;
  351. procedure TTestDBBasics.TestSetRecNo;
  352. begin
  353. with DBConnector.GetNDataset(15) do
  354. begin
  355. Open;
  356. RecNo := 1;
  357. AssertEquals(1,fields[0].AsInteger);
  358. AssertEquals(1,RecNo);
  359. RecNo := 2;
  360. AssertEquals(2,fields[0].AsInteger);
  361. AssertEquals(2,RecNo);
  362. RecNo := 8;
  363. AssertEquals(8,fields[0].AsInteger);
  364. AssertEquals(8,RecNo);
  365. RecNo := 15;
  366. AssertEquals(15,fields[0].AsInteger);
  367. AssertEquals(15,RecNo);
  368. RecNo := 3;
  369. AssertEquals(3,fields[0].AsInteger);
  370. AssertEquals(3,RecNo);
  371. RecNo := 14;
  372. AssertEquals(14,fields[0].AsInteger);
  373. AssertEquals(14,RecNo);
  374. RecNo := 15;
  375. AssertEquals(15,fields[0].AsInteger);
  376. AssertEquals(15,RecNo);
  377. // test for exceptions...
  378. { RecNo := 16;
  379. AssertEquals(15,fields[0].AsInteger);
  380. AssertEquals(15,RecNo);}
  381. Close;
  382. end;
  383. end;
  384. procedure TTestDBBasics.TestRequired;
  385. begin
  386. with DBConnector.GetNDataset(2) do
  387. begin
  388. Open;
  389. FieldByName('ID').Required := True;
  390. Append;
  391. AssertException(EDatabaseError,Post);
  392. FieldByName('ID').AsInteger := 1000;
  393. Post;
  394. Close;
  395. end;
  396. end;
  397. procedure TTestDBBasics.SetUp;
  398. begin
  399. DBConnector.StartTest;
  400. end;
  401. procedure TTestDBBasics.TearDown;
  402. begin
  403. DBConnector.StopTest;
  404. end;
  405. procedure TTestDBBasics.TestBookmarks;
  406. var BM1,BM2,BM3,BM4,BM5 : TBookmark;
  407. begin
  408. with DBConnector.GetNDataset(true,14) do
  409. begin
  410. AssertNull(GetBookmark);
  411. open;
  412. BM1:=GetBookmark; // id=1, BOF
  413. next;next;
  414. BM2:=GetBookmark; // id=3
  415. next;next;next;
  416. BM3:=GetBookmark; // id=6
  417. next;next;next;next;next;next;next;next;
  418. BM4:=GetBookmark; // id=14
  419. next;
  420. BM5:=GetBookmark; // id=14, EOF
  421. GotoBookmark(BM2);
  422. AssertEquals(3,FieldByName('id').AsInteger);
  423. GotoBookmark(BM1);
  424. AssertEquals(1,FieldByName('id').AsInteger);
  425. GotoBookmark(BM3);
  426. AssertEquals(6,FieldByName('id').AsInteger);
  427. GotoBookmark(BM4);
  428. AssertEquals(14,FieldByName('id').AsInteger);
  429. GotoBookmark(BM3);
  430. AssertEquals(6,FieldByName('id').AsInteger);
  431. GotoBookmark(BM5);
  432. AssertEquals(14,FieldByName('id').AsInteger);
  433. GotoBookmark(BM1);
  434. AssertEquals(1,FieldByName('id').AsInteger);
  435. next;
  436. delete;
  437. GotoBookmark(BM2);
  438. AssertEquals(3,FieldByName('id').AsInteger);
  439. delete;delete;
  440. GotoBookmark(BM3);
  441. AssertEquals(6,FieldByName('id').AsInteger);
  442. GotoBookmark(BM1);
  443. AssertEquals(1,FieldByName('id').AsInteger);
  444. insert;
  445. fieldbyname('id').AsInteger:=20;
  446. insert;
  447. fieldbyname('id').AsInteger:=21;
  448. insert;
  449. fieldbyname('id').AsInteger:=22;
  450. insert;
  451. fieldbyname('id').AsInteger:=23;
  452. post;
  453. GotoBookmark(BM3);
  454. AssertEquals(6,FieldByName('id').AsInteger);
  455. GotoBookmark(BM1);
  456. AssertEquals(1,FieldByName('id').AsInteger);
  457. GotoBookmark(BM5);
  458. AssertEquals(14,FieldByName('id').AsInteger);
  459. end;
  460. end;
  461. procedure TTestDBBasics.TestFirst;
  462. var i : integer;
  463. begin
  464. with DBConnector.GetNDataset(true,14) do
  465. begin
  466. open;
  467. AssertEquals(1,FieldByName('ID').AsInteger);
  468. First;
  469. AssertEquals(1,FieldByName('ID').AsInteger);
  470. next;
  471. AssertEquals(2,FieldByName('ID').AsInteger);
  472. First;
  473. AssertEquals(1,FieldByName('ID').AsInteger);
  474. for i := 0 to 12 do
  475. next;
  476. AssertEquals(14,FieldByName('ID').AsInteger);
  477. First;
  478. AssertEquals(1,FieldByName('ID').AsInteger);
  479. close;
  480. end;
  481. end;
  482. procedure TTestDBBasics.TestDelete1;
  483. begin
  484. FTestDelete1(false);
  485. end;
  486. procedure TTestDBBasics.TestDelete2;
  487. begin
  488. FTestDelete2(false);
  489. end;
  490. procedure TTestDBBasics.TestCancelUpdDelete1;
  491. begin
  492. FTestDelete1(true);
  493. end;
  494. procedure TTestDBBasics.TestCancelUpdDelete2;
  495. begin
  496. FTestDelete2(true);
  497. end;
  498. procedure TTestDBBasics.FTestDelete1(TestCancelUpdate : boolean);
  499. // Test the deletion of records, including the first and the last one
  500. var i : integer;
  501. ds : TDataset;
  502. begin
  503. ds := DBConnector.GetNDataset(true,17);
  504. with ds do
  505. begin
  506. Open;
  507. for i := 0 to 16 do if i mod 4=0 then
  508. delete
  509. else
  510. next;
  511. First;
  512. for i := 0 to 16 do
  513. begin
  514. if i mod 4<>0 then
  515. begin
  516. AssertEquals(i+1,FieldByName('ID').AsInteger);
  517. AssertEquals('TestName'+inttostr(i+1),FieldByName('NAME').AsString);
  518. next;
  519. end;
  520. end;
  521. end;
  522. if TestCancelUpdate then
  523. begin
  524. if not (ds is TBufDataset) then
  525. Ignore('This test only applies to TBufDataset and descendents.');
  526. with TBufDataset(ds) do
  527. begin
  528. CancelUpdates;
  529. First;
  530. for i := 0 to 16 do
  531. begin
  532. AssertEquals(i+1,FieldByName('ID').AsInteger);
  533. AssertEquals('TestName'+inttostr(i+1),FieldByName('NAME').AsString);
  534. next;
  535. end;
  536. close;
  537. end;
  538. end;
  539. end;
  540. procedure TTestDBBasics.FTestDelete2(TestCancelUpdate : boolean);
  541. // Test the deletion of edited and appended records
  542. var i : integer;
  543. ds : TDataset;
  544. begin
  545. ds := DBConnector.GetNDataset(true,17);
  546. with ds do
  547. begin
  548. Open;
  549. for i := 0 to 16 do
  550. begin
  551. if i mod 4=0 then
  552. begin
  553. edit;
  554. fieldbyname('name').AsString:='this record will be gone soon';
  555. post;
  556. end;
  557. next;
  558. end;
  559. for i := 17 to 20 do
  560. begin
  561. append;
  562. fieldbyname('id').AsInteger:=i+1;
  563. fieldbyname('name').AsString:='TestName'+inttostr(i+1);
  564. post;
  565. end;
  566. first;
  567. for i := 0 to 20 do if i mod 4=0 then
  568. delete
  569. else
  570. next;
  571. First;
  572. i := 0;
  573. for i := 0 to 20 do
  574. begin
  575. if i mod 4<>0 then
  576. begin
  577. AssertEquals(i+1,FieldByName('ID').AsInteger);
  578. AssertEquals('TestName'+inttostr(i+1),FieldByName('NAME').AsString);
  579. next;
  580. end;
  581. end;
  582. end;
  583. if TestCancelUpdate then
  584. begin
  585. if not (ds is TBufDataset) then
  586. Ignore('This test only applies to TBufDataset and descendents.');
  587. with TBufDataset(ds) do
  588. begin
  589. CancelUpdates;
  590. First;
  591. for i := 0 to 16 do
  592. begin
  593. AssertEquals(i+1,FieldByName('ID').AsInteger);
  594. AssertEquals('TestName'+inttostr(i+1),FieldByName('NAME').AsString);
  595. next;
  596. end;
  597. close;
  598. end;
  599. end;
  600. end;
  601. procedure TTestDBBasics.TestOnFilterProc(DataSet: TDataSet; var Accept: Boolean);
  602. var a : TDataSetState;
  603. begin
  604. Accept := odd(Dataset.FieldByName('ID').AsInteger);
  605. end;
  606. procedure TTestDBBasics.TestOnFilter;
  607. var tel : byte;
  608. begin
  609. with DBConnector.GetNDataset(15) do
  610. begin
  611. OnFilterRecord := TestOnFilterProc;
  612. Filtered := True;
  613. Open;
  614. for tel := 1 to 8 do
  615. begin
  616. AssertTrue(odd(FieldByName('ID').asinteger));
  617. next;
  618. end;
  619. AssertTrue(EOF);
  620. end;
  621. end;
  622. procedure TTestDBBasics.TestIntFilter;
  623. var tel : byte;
  624. begin
  625. with DBConnector.GetNDataset(15) do
  626. begin
  627. Filtered := True;
  628. Filter := '(id>4) and (id<9)';
  629. Open;
  630. for tel := 5 to 8 do
  631. begin
  632. AssertEquals(tel,FieldByName('ID').asinteger);
  633. next;
  634. end;
  635. AssertTrue(EOF);
  636. Close;
  637. end;
  638. end;
  639. procedure TTestDBBasics.TestRecordcountAfterReopen;
  640. var
  641. datalink1: tdatalink;
  642. datasource1: tdatasource;
  643. query1: TDataSet;
  644. begin
  645. query1:= DBConnector.GetNDataset(11);
  646. datalink1:= TDataLink.create;
  647. datasource1:= tdatasource.create(nil);
  648. try
  649. datalink1.datasource:= datasource1;
  650. datasource1.dataset:= query1;
  651. query1.active := true;
  652. query1.active := False;
  653. AssertEquals(0, THackDataLink(datalink1).RecordCount);
  654. query1.active := true;
  655. AssertTrue(THackDataLink(datalink1).RecordCount>0);
  656. query1.active := false;
  657. finally
  658. datalink1.free;
  659. datasource1.free;
  660. end;
  661. end;
  662. procedure TTestDBBasics.TestStringFilter;
  663. var tel : byte;
  664. begin
  665. with DBConnector.GetNDataset(15) do
  666. begin
  667. Open;
  668. //FilterOptions := [foNoPartialCompare];
  669. //FilterOptions := [];
  670. Filter := '(name=''*Name3'')';
  671. Filtered := True;
  672. AssertFalse(EOF);
  673. AssertEquals(3,FieldByName('ID').asinteger);
  674. AssertEquals('TestName3',FieldByName('NAME').asstring);
  675. next;
  676. AssertTrue(EOF);
  677. Close;
  678. end;
  679. end;
  680. procedure TTestDBBasics.TestAddIndexFieldType(AFieldType: TFieldType; ActiveDS : boolean);
  681. var ds : TBufDataset;
  682. FList : TStringList;
  683. LastValue : Variant;
  684. begin
  685. ds := DBConnector.GetFieldDataset as TBufDataset;
  686. with ds do
  687. begin
  688. if not ActiveDS then
  689. begin
  690. AddIndex('testindex','F'+FieldTypeNames[AfieldType]);
  691. IndexName:='testindex';
  692. end
  693. else
  694. MaxIndexesCount := 3;
  695. try
  696. open;
  697. except
  698. if not assigned(ds.FindField('F'+FieldTypeNames[AfieldType])) then
  699. Ignore('Fields of the type ' + FieldTypeNames[AfieldType] + ' are not supported by this type of dataset')
  700. else
  701. raise;
  702. end;
  703. if ActiveDS then
  704. begin
  705. if not assigned(ds.FindField('F'+FieldTypeNames[AfieldType])) then
  706. Ignore('Fields of the type ' + FieldTypeNames[AfieldType] + ' are not supported by this type of dataset');
  707. AddIndex('testindex','F'+FieldTypeNames[AfieldType]);
  708. IndexName:='testindex';
  709. First;
  710. end;
  711. LastValue:=null;
  712. while not eof do
  713. begin
  714. AssertTrue(LastValue<=FieldByName('F'+FieldTypeNames[AfieldType]).AsVariant);
  715. LastValue:=FieldByName('F'+FieldTypeNames[AfieldType]).AsVariant;
  716. Next;
  717. end;
  718. while not bof do
  719. begin
  720. AssertTrue(LastValue>=FieldByName('F'+FieldTypeNames[AfieldType]).AsVariant);
  721. LastValue:=FieldByName('F'+FieldTypeNames[AfieldType]).AsVariant;
  722. Prior;
  723. end;
  724. end;
  725. end;
  726. procedure TTestDBBasics.TestAddIndexSmallInt;
  727. begin
  728. TestAddIndexFieldType(ftSmallint,False);
  729. end;
  730. procedure TTestDBBasics.TestAddIndexBoolean;
  731. begin
  732. TestAddIndexFieldType(ftBoolean,False);
  733. end;
  734. procedure TTestDBBasics.TestAddIndexFloat;
  735. begin
  736. TestAddIndexFieldType(ftFloat,False);
  737. end;
  738. procedure TTestDBBasics.TestAddIndexInteger;
  739. begin
  740. TestAddIndexFieldType(ftInteger,False);
  741. end;
  742. procedure TTestDBBasics.TestAddIndexLargeInt;
  743. begin
  744. TestAddIndexFieldType(ftLargeint,False);
  745. end;
  746. procedure TTestDBBasics.TestAddIndexDateTime;
  747. begin
  748. TestAddIndexFieldType(ftDateTime,False);
  749. end;
  750. procedure TTestDBBasics.TestAddIndexCurrency;
  751. begin
  752. TestAddIndexFieldType(ftCurrency,False);
  753. end;
  754. procedure TTestDBBasics.TestAddIndexBCD;
  755. begin
  756. TestAddIndexFieldType(ftBCD,False);
  757. end;
  758. procedure TTestDBBasics.TestAddIndex;
  759. var ds : TBufDataset;
  760. AFieldType : TFieldType;
  761. FList : TStringList;
  762. i : integer;
  763. begin
  764. ds := DBConnector.GetFieldDataset as TBufDataset;
  765. with ds do
  766. begin
  767. AFieldType:=ftString;
  768. AddIndex('testindex','F'+FieldTypeNames[AfieldType]);
  769. FList := TStringList.Create;
  770. FList.Sorted:=true;
  771. FList.CaseSensitive:=True;
  772. FList.Duplicates:=dupAccept;
  773. open;
  774. while not eof do
  775. begin
  776. flist.Add(FieldByName('F'+FieldTypeNames[AfieldType]).AsString);
  777. Next;
  778. end;
  779. IndexName:='testindex';
  780. first;
  781. i:=0;
  782. while not eof do
  783. begin
  784. AssertEquals(flist[i],FieldByName('F'+FieldTypeNames[AfieldType]).AsString);
  785. inc(i);
  786. Next;
  787. end;
  788. while not bof do
  789. begin
  790. dec(i);
  791. AssertEquals(flist[i],FieldByName('F'+FieldTypeNames[AfieldType]).AsString);
  792. Prior;
  793. end;
  794. end;
  795. end;
  796. procedure TTestDBBasics.TestInactSwitchIndex;
  797. // Test if the default-index is properly build when the active index is not
  798. // the default-index while opening then dataset
  799. var ds : TBufDataset;
  800. AFieldType : TFieldType;
  801. i : integer;
  802. begin
  803. ds := DBConnector.GetFieldDataset as TBufDataset;
  804. with ds do
  805. begin
  806. AFieldType:=ftString;
  807. AddIndex('testindex','F'+FieldTypeNames[AfieldType]);
  808. IndexName:='testindex';
  809. open;
  810. IndexName:=''; // This should set the default index (default_order)
  811. first;
  812. i := 0;
  813. while not eof do
  814. begin
  815. AssertEquals(testStringValues[i],FieldByName('F'+FieldTypeNames[AfieldType]).AsString);
  816. inc(i);
  817. Next;
  818. end;
  819. end;
  820. end;
  821. procedure TTestDBBasics.TestAddIndexActiveDS;
  822. var ds : TBufDataset;
  823. I : integer;
  824. begin
  825. TestAddIndexFieldType(ftString,true);
  826. end;
  827. procedure TTestDBBasics.TestAddIndexEditDS;
  828. var ds : TBufDataset;
  829. I : integer;
  830. LastValue : String;
  831. begin
  832. ds := DBConnector.GetNDataset(True,5) as TBufDataset;
  833. with ds do
  834. begin
  835. MaxIndexesCount:=3;
  836. open;
  837. edit;
  838. FieldByName('name').asstring := 'Zz';
  839. post;
  840. next;
  841. next;
  842. edit;
  843. FieldByName('name').asstring := 'aA';
  844. post;
  845. AddIndex('test','name');
  846. first;
  847. ds.IndexName:='test';
  848. first;
  849. LastValue:=FieldByName('name').AsString;
  850. while not eof do
  851. begin
  852. AssertTrue(LastValue<=FieldByName('name').AsString);
  853. Next;
  854. end;
  855. end;
  856. end;
  857. procedure TTestDBBasics.TestcalculatedField_OnCalcfields(DataSet: TDataSet);
  858. begin
  859. case dataset.fieldbyname('ID').asinteger of
  860. 1 : dataset.fieldbyname('CALCFLD').AsInteger := 5;
  861. 2 : dataset.fieldbyname('CALCFLD').AsInteger := 70000;
  862. 3 : dataset.fieldbyname('CALCFLD').Clear;
  863. 4 : dataset.fieldbyname('CALCFLD').AsInteger := 1234;
  864. 10 : dataset.fieldbyname('CALCFLD').Clear;
  865. else
  866. dataset.fieldbyname('CALCFLD').AsInteger := 1;
  867. end;
  868. end;
  869. procedure TTestDBBasics.TestCalculatedField;
  870. var ds : TDataset;
  871. AFld1, AFld2, AFld3 : Tfield;
  872. begin
  873. ds := DBConnector.GetNDataset(5);
  874. with ds do
  875. begin
  876. AFld1 := TIntegerField.Create(ds);
  877. AFld1.FieldName := 'ID';
  878. AFld1.DataSet := ds;
  879. AFld2 := TStringField.Create(ds);
  880. AFld2.FieldName := 'NAME';
  881. AFld2.DataSet := ds;
  882. AFld3 := TIntegerField.Create(ds);
  883. AFld3.FieldName := 'CALCFLD';
  884. AFld3.DataSet := ds;
  885. Afld3.FieldKind := fkCalculated;
  886. AssertEquals(3,FieldCount);
  887. ds.OnCalcFields := TestcalculatedField_OnCalcfields;
  888. open;
  889. AssertEquals(1,FieldByName('ID').asinteger);
  890. AssertEquals(5,FieldByName('CALCFLD').asinteger);
  891. next;
  892. AssertEquals(70000,FieldByName('CALCFLD').asinteger);
  893. next;
  894. AssertEquals(true,FieldByName('CALCFLD').isnull);
  895. next;
  896. AssertEquals(1234,FieldByName('CALCFLD').AsInteger);
  897. edit;
  898. FieldByName('ID').AsInteger := 10;
  899. post;
  900. AssertEquals(true,FieldByName('CALCFLD').isnull);
  901. close;
  902. AFld1.Free;
  903. AFld2.Free;
  904. AFld3.Free;
  905. end;
  906. end;
  907. procedure TTestDBBasics.TestEofAfterFirst;
  908. begin
  909. with DBConnector.GetNDataset(0) do
  910. begin
  911. open;
  912. AssertTrue(eof);
  913. AssertTrue(BOF);
  914. first;
  915. AssertTrue(eof);
  916. AssertTrue(BOF);
  917. end;
  918. end;
  919. procedure TTestDBBasics.TestfieldDefinition(AFieldType : TFieldType;ADatasize : integer;var ADS : TDataset; var AFld: TField);
  920. var i : byte;
  921. begin
  922. ADS := DBConnector.GetFieldDataset;
  923. ADS.Open;
  924. AFld := ADS.FindField('F'+FieldTypeNames[AfieldType]);
  925. if not assigned (AFld) then
  926. Ignore('Fields of the type ' + FieldTypeNames[AfieldType] + ' are not supported by this type of dataset');
  927. AssertTrue(Afld.DataType = AFieldType);
  928. AssertEquals(ADatasize,Afld.DataSize );
  929. end;
  930. procedure TTestDBBasics.TestSupportIntegerFields;
  931. var i : byte;
  932. ds : TDataset;
  933. Fld : TField;
  934. begin
  935. TestfieldDefinition(ftInteger,4,ds,Fld);
  936. for i := 0 to testValuesCount-1 do
  937. begin
  938. AssertEquals(testIntValues[i],Fld.AsInteger);
  939. ds.Next;
  940. end;
  941. ds.close;
  942. end;
  943. procedure TTestDBBasics.TestSupportSmallIntFields;
  944. var i : byte;
  945. ds : TDataset;
  946. Fld : TField;
  947. begin
  948. TestfieldDefinition(ftSmallint,2,ds,Fld);
  949. for i := 0 to testValuesCount-1 do
  950. begin
  951. AssertEquals(testSmallIntValues[i],Fld.AsInteger);
  952. ds.Next;
  953. end;
  954. ds.close;
  955. end;
  956. procedure TTestDBBasics.TestSupportStringFields;
  957. var i : byte;
  958. ds : TDataset;
  959. Fld : TField;
  960. begin
  961. TestfieldDefinition(ftString,11,ds,Fld);
  962. for i := 0 to testValuesCount-1 do
  963. begin
  964. AssertEquals(testStringValues[i],Fld.AsString);
  965. ds.Next;
  966. end;
  967. ds.close;
  968. end;
  969. procedure TTestDBBasics.TestSupportBooleanFields;
  970. var i : byte;
  971. ds : TDataset;
  972. Fld : TField;
  973. begin
  974. TestfieldDefinition(ftBoolean,2,ds,Fld);
  975. for i := 0 to testValuesCount-1 do
  976. begin
  977. AssertEquals(testBooleanValues[i],Fld.AsBoolean);
  978. ds.Next;
  979. end;
  980. ds.close;
  981. end;
  982. procedure TTestDBBasics.TestSupportFloatFields;
  983. var i : byte;
  984. ds : TDataset;
  985. Fld : TField;
  986. begin
  987. TestfieldDefinition(ftFloat,8,ds,Fld);
  988. for i := 0 to testValuesCount-1 do
  989. begin
  990. AssertEquals(testFloatValues[i],Fld.AsFloat);
  991. ds.Next;
  992. end;
  993. ds.close;
  994. end;
  995. procedure TTestDBBasics.TestSupportLargeIntFields;
  996. var i : byte;
  997. ds : TDataset;
  998. Fld : TField;
  999. begin
  1000. TestfieldDefinition(ftLargeint,8,ds,Fld);
  1001. for i := 0 to testValuesCount-1 do
  1002. begin
  1003. AssertEquals(testLargeIntValues[i],Fld.AsLargeInt);
  1004. ds.Next;
  1005. end;
  1006. ds.close;
  1007. end;
  1008. procedure TTestDBBasics.TestSupportDateFields;
  1009. var i : byte;
  1010. ds : TDataset;
  1011. Fld : TField;
  1012. begin
  1013. TestfieldDefinition(ftDate,8,ds,Fld);
  1014. for i := 0 to testValuesCount-1 do
  1015. begin
  1016. AssertEquals(testDateValues[i],FormatDateTime('yyyy/mm/dd',Fld.AsDateTime));
  1017. ds.Next;
  1018. end;
  1019. ds.close;
  1020. end;
  1021. procedure TTestDBBasics.TestSupportCurrencyFields;
  1022. var i : byte;
  1023. ds : TDataset;
  1024. Fld : TField;
  1025. begin
  1026. TestfieldDefinition(ftCurrency,8,ds,Fld);
  1027. for i := 0 to testValuesCount-1 do
  1028. begin
  1029. AssertEquals(testCurrencyValues[i],Fld.AsCurrency);
  1030. AssertEquals(testCurrencyValues[i],Fld.AsFloat);
  1031. ds.Next;
  1032. end;
  1033. ds.close;
  1034. end;
  1035. procedure TTestDBBasics.TestSupportBCDFields;
  1036. var i : byte;
  1037. ds : TDataset;
  1038. Fld : TField;
  1039. begin
  1040. TestfieldDefinition(ftBCD,8,ds,Fld);
  1041. for i := 0 to testValuesCount-1 do
  1042. begin
  1043. AssertEquals(testCurrencyValues[i],Fld.AsCurrency);
  1044. AssertEquals(testCurrencyValues[i],Fld.AsFloat);
  1045. ds.Next;
  1046. end;
  1047. ds.close;
  1048. end;
  1049. procedure TTestDBBasics.TestDoubleClose;
  1050. begin
  1051. with DBConnector.GetNDataset(1) do
  1052. begin
  1053. close;
  1054. close;
  1055. open;
  1056. close;
  1057. close;
  1058. end;
  1059. end;
  1060. procedure TTestDBBasics.TestAssignFieldftString;
  1061. var AParam : TParam;
  1062. AField : TField;
  1063. begin
  1064. AParam := TParam.Create(nil);
  1065. with DBConnector.GetNDataset(1) do
  1066. begin
  1067. open;
  1068. AField := fieldbyname('name');
  1069. AParam.AssignField(AField);
  1070. AssertTrue(ftString=AParam.DataType);
  1071. close;
  1072. end;
  1073. AParam.Free;
  1074. end;
  1075. procedure TTestDBBasics.TestAssignFieldftFixedChar;
  1076. var AParam : TParam;
  1077. AField : TField;
  1078. begin
  1079. AParam := TParam.Create(nil);
  1080. with DBConnector.GetNDataset(1) do
  1081. begin
  1082. open;
  1083. AField := fieldbyname('name');
  1084. (AField as tstringfield).FixedChar := true;
  1085. AParam.AssignField(AField);
  1086. AssertTrue(ftFixedChar=AParam.DataType);
  1087. close;
  1088. end;
  1089. AParam.Free;
  1090. end;
  1091. procedure TTestDBBasics.TestBufDatasetCancelUpd;
  1092. var i : byte;
  1093. begin
  1094. if not (DBConnector.GetNDataset(5) is TBufDataset) then
  1095. Ignore('This test only applies to TBufDataset and descendents.');
  1096. with DBConnector.GetNDataset(5) as TBufDataset do
  1097. begin
  1098. open;
  1099. next;
  1100. next;
  1101. edit;
  1102. FieldByName('name').AsString := 'changed';
  1103. post;
  1104. next;
  1105. delete;
  1106. CancelUpdates;
  1107. First;
  1108. for i := 1 to 5 do
  1109. begin
  1110. AssertEquals(i,fields[0].AsInteger);
  1111. AssertEquals('TestName'+inttostr(i),fields[1].AsString);
  1112. Next;
  1113. end;
  1114. end;
  1115. end;
  1116. procedure TTestDBBasics.Testbug7007;
  1117. var
  1118. datalink1: tdatalink;
  1119. datasource1: tdatasource;
  1120. query1: TDataSet;
  1121. begin
  1122. query1:= DBConnector.GetNDataset(6);
  1123. datalink1:= TTestDataLink.create;
  1124. datasource1:= tdatasource.create(nil);
  1125. try
  1126. datalink1.datasource:= datasource1;
  1127. datasource1.dataset:= query1;
  1128. datalink1.datasource:= datasource1;
  1129. DataEvents := '';
  1130. query1.open;
  1131. datalink1.buffercount:= query1.recordcount;
  1132. AssertEquals('deUpdateState:0;',DataEvents);
  1133. AssertEquals(0, datalink1.ActiveRecord);
  1134. AssertEquals(6, datalink1.RecordCount);
  1135. AssertEquals(6, query1.RecordCount);
  1136. AssertEquals(1, query1.RecNo);
  1137. DataEvents := '';
  1138. query1.append;
  1139. AssertEquals('deCheckBrowseMode:0;deUpdateState:0;deDataSetChange:0;',DataEvents);
  1140. AssertEquals(5, datalink1.ActiveRecord);
  1141. AssertEquals(6, datalink1.RecordCount);
  1142. AssertEquals(6, query1.RecordCount);
  1143. AssertTrue(query1.RecNo in [0,7]);
  1144. DataEvents := '';
  1145. query1.cancel;
  1146. AssertEquals('deCheckBrowseMode:0;deUpdateState:0;deDataSetChange:0;',DataEvents);
  1147. AssertEquals(5, datalink1.ActiveRecord);
  1148. AssertEquals(6, datalink1.RecordCount);
  1149. AssertEquals(6, query1.RecordCount);
  1150. AssertEquals(6, query1.RecNo);
  1151. finally
  1152. datalink1.free;
  1153. datasource1.free;
  1154. end;
  1155. end;
  1156. procedure TTestDBBasics.TestBug6893;
  1157. var
  1158. datalink1: tdatalink;
  1159. datasource1: tdatasource;
  1160. query1: TDataSet;
  1161. begin
  1162. query1:= DBConnector.GetNDataset(25);
  1163. datalink1:= TDataLink.create;
  1164. datasource1:= tdatasource.create(nil);
  1165. try
  1166. datalink1.datasource:= datasource1;
  1167. datasource1.dataset:= query1;
  1168. datalink1.buffercount:= 5;
  1169. query1.active := true;
  1170. query1.MoveBy(20);
  1171. AssertEquals(5, THackDataLink(datalink1).Firstrecord);
  1172. AssertEquals(4, datalink1.ActiveRecord);
  1173. AssertEquals(21, query1.RecNo);
  1174. query1.active := False;
  1175. AssertEquals(0, THackDataLink(datalink1).Firstrecord);
  1176. AssertEquals(0, datalink1.ActiveRecord);
  1177. query1.active := true;
  1178. AssertEquals(0, THackDataLink(datalink1).Firstrecord);
  1179. AssertEquals(0, datalink1.ActiveRecord);
  1180. AssertEquals(1, query1.RecNo);
  1181. finally
  1182. datalink1.free;
  1183. datasource1.free;
  1184. end;
  1185. end;
  1186. procedure TTestDBBasics.TestBufDatasetCancelUpd1;
  1187. var i : byte;
  1188. begin
  1189. if not (DBConnector.GetNDataset(5) is TBufDataset) then
  1190. Ignore('This test only applies to TBufDataset and descendents.');
  1191. with DBConnector.GetNDataset(5) as TBufDataset do
  1192. begin
  1193. open;
  1194. next;
  1195. next;
  1196. delete;
  1197. insert;
  1198. FieldByName('id').AsInteger := 100;
  1199. post;
  1200. CancelUpdates;
  1201. last;
  1202. for i := 5 downto 1 do
  1203. begin
  1204. AssertEquals(i,fields[0].AsInteger);
  1205. AssertEquals('TestName'+inttostr(i),fields[1].AsString);
  1206. Prior;
  1207. end;
  1208. end;
  1209. end;
  1210. procedure TTestDBBasics.TestNullAtOpen;
  1211. begin
  1212. with dbconnector.getndataset(0) do
  1213. begin
  1214. active:= true;
  1215. AssertTrue('Field isn''t NULL on a just-opened empty dataset',fieldbyname('id').IsNull);
  1216. append;
  1217. AssertTrue('Field isn''t NULL after append on an empty dataset',fieldbyname('id').IsNull);
  1218. fieldbyname('id').asinteger:= 123;
  1219. cancel;
  1220. AssertTrue('Field isn''t NULL after cancel',fieldbyname('id').IsNull);
  1221. end;
  1222. end;
  1223. { TSQLTestSetup }
  1224. procedure TDBBasicsTestSetup.OneTimeSetup;
  1225. begin
  1226. InitialiseDBConnector;
  1227. end;
  1228. procedure TDBBasicsTestSetup.OneTimeTearDown;
  1229. begin
  1230. FreeAndNil(DBConnector);
  1231. end;
  1232. initialization
  1233. RegisterTestDecorator(TDBBasicsTestSetup, TTestDBBasics);
  1234. end.