1 |
+ |
(* |
2 |
+ |
* IBX Test suite. This program is used to test the IBX non-visual |
3 |
+ |
* components and provides a semi-automated pass/fail check for each test. |
4 |
+ |
* |
5 |
+ |
* The contents of this file are subject to the Initial Developer's |
6 |
+ |
* Public License Version 1.0 (the "License"); you may not use this |
7 |
+ |
* file except in compliance with the License. You may obtain a copy |
8 |
+ |
* of the License here: |
9 |
+ |
* |
10 |
+ |
* http://www.firebirdsql.org/index.php?op=doc&id=idpl |
11 |
+ |
* |
12 |
+ |
* Software distributed under the License is distributed on an "AS |
13 |
+ |
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or |
14 |
+ |
* implied. See the License for the specific language governing rights |
15 |
+ |
* and limitations under the License. |
16 |
+ |
* |
17 |
+ |
* The Initial Developer of the Original Code is Tony Whyman. |
18 |
+ |
* |
19 |
+ |
* The Original Code is (C) 2021 Tony Whyman, MWA Software |
20 |
+ |
* (http://www.mwasoftware.co.uk). |
21 |
+ |
* |
22 |
+ |
* All Rights Reserved. |
23 |
+ |
* |
24 |
+ |
* Contributor(s): ______________________________________. |
25 |
+ |
* |
26 |
+ |
*) |
27 |
|
unit Test17; |
28 |
|
|
29 |
|
{$mode objfpc}{$H+} |
261 |
|
|
262 |
|
procedure TTest17.RunTest(CharSet: AnsiString; SQLDialect: integer); |
263 |
|
var lastKey: integer; |
264 |
+ |
i: integer; |
265 |
+ |
B: TBookmark; |
266 |
|
begin |
267 |
|
IBDatabase.CreateDatabase; |
268 |
|
try |
288 |
|
FieldByName('PlainText').AsString := 'This is the update test'; |
289 |
|
Post; |
290 |
|
PrintDataSetRow(FIBDataSet1); |
291 |
< |
writeln(OutFile,'Now delete the first row'); |
291 |
> |
writeln(Outfile,'Show whole Dataset'); |
292 |
|
PrintDataSet(FIBDataSet1); |
293 |
+ |
writeln(OutFile,'Now delete the first row'); |
294 |
|
First; |
295 |
|
Delete; |
296 |
|
PrintDataSet(FIBDataSet1); |
337 |
|
Active := true; |
338 |
|
PrintDataSet(FIBDataSet1); |
339 |
|
|
340 |
< |
{See https://bugs.freepascal.org/view.php?id=37900} |
312 |
< |
|
313 |
< |
(* IBTransaction.Rollback; |
340 |
> |
IBTransaction.Rollback; |
341 |
|
IBTransaction.Active := true; |
342 |
|
writeln(Outfile); |
343 |
|
writeln(Outfile,'Unidirectional editing'); |
354 |
|
Refresh; |
355 |
|
writeln(OutFile,'After Refresh - unidirectional'); |
356 |
|
PrintDataSetRow(FIBDataSet1); |
357 |
< |
writeln(OutFile,'Append and Update'); |
357 |
> |
writeln(OutFile,' Record Count = ',FIBDataSet1.RecordCount); |
358 |
> |
writeln(OutFile,'Insert and Update'); |
359 |
|
Insert; |
360 |
|
FieldByName('PlainText').AsString := 'This is another test - unidirectional'; |
361 |
|
Post; |
364 |
|
FieldByName('PlainText').AsString := 'This is the update test - unidirectional'; |
365 |
|
Post; |
366 |
|
PrintDataSetRow(FIBDataSet1); |
367 |
< |
writeln(OutFile,'Now delete the first row - unidirectional'); |
368 |
< |
PrintDataSet(FIBDataSet1); |
369 |
< |
First; |
367 |
> |
writeln(OutFile,'Now delete the first row - unidirectional with Record Count = ',FIBDataSet1.RecordCount); |
368 |
> |
Active := false; |
369 |
> |
Active := true; |
370 |
|
Delete; |
371 |
< |
PrintDataSet(FIBDataSet1); |
371 |
> |
writeln(OutFile,'Show Current Row'); |
372 |
> |
PrintDataSetRow(FIBDataSet1); |
373 |
> |
writeln(OutFile,' Record Count = ',FIBDataSet1.RecordCount); |
374 |
|
writeln(Outfile,'Ensure dataset saved to database'); |
375 |
|
Active := false; |
376 |
|
Active := true; |
377 |
< |
PrintDataSet(FIBDataSet1); *) |
377 |
> |
PrintDataSet(FIBDataSet1); |
378 |
|
|
379 |
|
end; |
380 |
|
writeln(Outfile,'=================================='); |
381 |
|
IBTransaction.Rollback; |
382 |
|
IBTransaction.Active := true; |
383 |
|
with FIBDataSet2 do |
384 |
< |
begin |
384 |
> |
try |
385 |
|
Active := true; |
386 |
|
writeln(OutFile,'FIBDataSet2: Simple Append'); |
387 |
|
Append; |
424 |
|
FieldByName('PlainText').AsString := 'This is a test'; |
425 |
|
Post; |
426 |
|
PrintDataSetRow(FIBDataSet2); |
427 |
< |
|
427 |
> |
except on E: Exception do |
428 |
> |
writeln(Outfile,E.Message); |
429 |
> |
end; |
430 |
> |
IBTransaction.Rollback; |
431 |
> |
IBTransaction.Active := true; |
432 |
> |
with FIBDataSet1 do |
433 |
> |
try |
434 |
> |
Unidirectional := false; |
435 |
> |
Active := true; |
436 |
> |
writeln(outfile,'----------------------------------------------'); |
437 |
> |
writeln(OutFile,'FIBDataSet1: Insert at start'); |
438 |
> |
for i := 1 to 2 do |
439 |
> |
begin |
440 |
> |
Append; |
441 |
> |
FieldByName('PlainText').AsString := 'Row ' + IntToStr(i); |
442 |
> |
Post; |
443 |
> |
end; |
444 |
> |
First; |
445 |
> |
Insert; |
446 |
> |
FieldByName('PlainText').AsString := 'This is an insert test'; |
447 |
> |
Post; |
448 |
> |
B := Bookmark; |
449 |
> |
PrintDataSet(FIBDataSet1); |
450 |
> |
writeln(outfile,'Delete inserted row'); |
451 |
> |
Bookmark := B; |
452 |
> |
Delete; |
453 |
> |
PrintDataSet(FIBDataSet1); |
454 |
> |
writeln(outfile,'Repeat'); |
455 |
> |
First; |
456 |
> |
Insert; |
457 |
> |
FieldByName('PlainText').AsString := 'This is an insert test #1'; |
458 |
> |
Post; |
459 |
> |
B := Bookmark; |
460 |
> |
PrintDataSet(FIBDataSet1); |
461 |
> |
writeln(outfile,'Delete inserted row'); |
462 |
> |
Bookmark := B; |
463 |
> |
Delete; |
464 |
> |
PrintDataSet(FIBDataSet1); |
465 |
> |
writeln(outfile,'Insert/Delete after first row'); |
466 |
> |
Next; |
467 |
> |
Insert; |
468 |
> |
FieldByName('PlainText').AsString := 'This is an insert test #2'; |
469 |
> |
Post; |
470 |
> |
B := Bookmark; |
471 |
> |
PrintDataSet(FIBDataSet1); |
472 |
> |
writeln(outfile,'Delete inserted row'); |
473 |
> |
Bookmark := B; |
474 |
> |
Delete; |
475 |
> |
PrintDataSet(FIBDataSet1); |
476 |
> |
writeln(outfile,'Insert/Delete at last row'); |
477 |
> |
Last; |
478 |
> |
Insert; |
479 |
> |
FieldByName('PlainText').AsString := 'This is an insert test #3'; |
480 |
> |
Post; |
481 |
> |
B := Bookmark; |
482 |
> |
PrintDataSet(FIBDataSet1); |
483 |
> |
writeln(outfile,'Delete inserted row'); |
484 |
> |
Bookmark := B; |
485 |
> |
Delete; |
486 |
> |
PrintDataSet(FIBDataSet1); |
487 |
> |
except on E: Exception do |
488 |
> |
writeln(Outfile,E.Message); |
489 |
|
end; |
490 |
+ |
|
491 |
|
finally |
492 |
|
IBDatabase.DropDatabase; |
493 |
|
end; |