1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
|
{
This file is part of the Free Pascal run time library.
Copyright (c) 2008 by the Free Pascal development team
FPCUnit SQLScript test.
See the file COPYING.FPC, included in this distribution,
for details about the copyright.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
**********************************************************************}
unit testcsqlscript;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, testregistry, sqlscript, fpcunit;
type
{ TMyScript }
TMyScript = class (TCustomSQLScript)
private
FExcept: string;
FStatements : TStrings;
FDirectives : TStrings;
FCommits : integer;
protected
procedure ExecuteStatement (SQLStatement: TStrings; var StopExecution: Boolean); override;
procedure ExecuteDirective (Directive, Argument: String; var StopExecution: Boolean); override;
procedure ExecuteCommit; override;
procedure DefaultDirectives; override;
public
constructor create (AnOwner: TComponent); override;
destructor destroy; override;
function StatementsExecuted : string;
function DirectivesExecuted : string;
property DoException : string read FExcept write FExcept;
property Aborted;
property Line;
property Directives;
property Defines;
property Script;
property Terminator;
property CommentsinSQL;
property UseSetTerm;
property UseCommit;
property UseDefines;
property OnException;
end;
{ TTestSQLScript }
TTestSQLScript = class (TTestCase)
private
Script : TMyScript;
exceptionstatement,
exceptionmessage : string;
UseContinue : boolean;
procedure Add (s :string);
procedure AssertStatDir (Statements, Directives : string);
procedure DoExecution;
procedure ExceptionHandler(Sender: TObject; Statement: TStrings; TheException: Exception; var Continue: boolean);
procedure TestDirectiveOnException3;
protected
procedure SetUp; override;
procedure TearDown; override;
published
procedure TestCreateDefaults;
procedure TestTerminator;
procedure TestSetTerm;
procedure TestUseSetTerm;
procedure TestComments;
procedure TestUseComments;
procedure TestCommit;
procedure TestUseCommit;
procedure TestDefine;
procedure TestUndefine;
procedure TestUndef;
procedure TestIfdef1;
procedure TestIfdef2;
procedure TestIfndef1;
procedure TestIfndef2;
procedure TestElse1;
procedure TestElse2;
procedure TestEndif1;
procedure TestEndif2;
procedure TestUseDefines;
procedure TestTermInComment;
procedure TestTermInQuotes1;
procedure TestTermInQuotes2;
procedure TestCommentInComment;
procedure TestCommentInQuotes1;
procedure TestCommentInQuotes2;
procedure TestQuote1InComment;
procedure TestQuote2InComment;
procedure TestQuoteInQuotes1;
procedure TestQuoteInQuotes2;
procedure TestStatementStop;
procedure TestDirectiveStop;
procedure TestStatementExeception;
procedure TestDirectiveException;
procedure TestCommitException;
procedure TestStatementOnExeception1;
procedure TestStatementOnExeception2;
procedure TestDirectiveOnException1;
procedure TestDirectiveOnException2;
procedure TestCommitOnException1;
procedure TestCommitOnException2;
end;
{ TTestEventSQLScript }
TTestEventSQLScript = class (TTestCase)
private
Script : TEventSQLScript;
StopToSend : boolean;
Received : string;
notifycount : integer;
LastSender : TObject;
procedure Notify (Sender : TObject);
procedure NotifyStatement (Sender: TObject; SQL_Statement: TStrings; var StopExecution: Boolean);
procedure NotifyDirective (Sender: TObject; Directive, Argument: AnsiString; var StopExecution: Boolean);
protected
procedure SetUp; override;
procedure TearDown; override;
published
procedure TestStatement;
procedure TestStatementStop;
procedure TestDirective;
procedure TestDirectiveStop;
procedure TestCommit;
procedure TestBeforeExec;
procedure TestAfterExec;
end;
implementation
{ TMyScript }
procedure TMyScript.ExecuteStatement(SQLStatement: TStrings; var StopExecution: Boolean);
var s : string;
r : integer;
begin
if (SQLStatement.count = 1) and (compareText(SQLStatement[0],'END')=0) then
StopExecution := true;
s := '';
for r := 0 to SQLstatement.count-1 do
begin
if s <> '' then
s := s + ' ';
s := s + SQLStatement[r];
end;
FStatements.Add (s);
if DoException <> '' then
raise exception.create(DoException);
end;
procedure TMyScript.ExecuteDirective(Directive, Argument: String; var StopExecution: Boolean);
begin
if Directive = 'STOP' then
StopExecution := true;
if Argument = '' then
FDirectives.Add (Directive)
else
FDirectives.Add (format('%s(%s)', [Directive, Argument]));
if DoException <> '' then
raise exception.create(DoException);
end;
procedure TMyScript.ExecuteCommit;
begin
inc (FCommits);
if DoException <> '' then
raise exception.create(DoException);
end;
procedure TMyScript.DefaultDirectives;
begin
inherited DefaultDirectives;
directives.add ('STOP');
end;
constructor TMyScript.create (AnOwner: TComponent);
begin
inherited create (AnOwner);
FStatements := TStringlist.Create;
FDirectives := TStringlist.Create;
FCommits := 0;
DoException := '';
end;
destructor TMyScript.destroy;
begin
FStatements.Free;
FDirectives.Free;
inherited destroy;
end;
function TMyScript.StatementsExecuted: string;
begin
result := FStatements.Commatext;
end;
function TMyScript.DirectivesExecuted: string;
begin
result := FDirectives.Commatext;
end;
{ TTestSQLScript }
procedure TTestSQLScript.Add(s: string);
begin
Script.Script.Add (s);
end;
procedure TTestSQLScript.AssertStatDir(Statements, Directives: string);
begin
AssertEquals ('Executed Statements', Statements, script.StatementsExecuted);
AssertEquals ('Executed Directives', Directives, script.DirectivesExecuted);
end;
procedure TTestSQLScript.DoExecution;
begin
script.execute;
end;
procedure TTestSQLScript.ExceptionHandler(Sender: TObject; Statement: TStrings;
TheException: Exception; var Continue: boolean);
var r : integer;
s : string;
begin
Continue := UseContinue;
if Statement.count > 0 then
s := Statement[0];
for r := 1 to Statement.count-1 do
s := s + ',' + Statement[r];
exceptionstatement := s;
exceptionmessage := TheException.message;
end;
procedure TTestSQLScript.SetUp;
begin
inherited SetUp;
Script := TMyscript.Create (nil);
end;
procedure TTestSQLScript.TearDown;
begin
Script.Free;
inherited TearDown;
end;
procedure TTestSQLScript.TestCreateDefaults;
begin
with Script do
begin
AssertEquals ('Terminator', ';', Terminator);
AssertTrue ('UseCommit', UseCommit);
AssertTrue ('UseSetTerm', UseSetTerm);
AssertTrue ('UseDefines', UseDefines);
AssertTrue ('CommentsInSQL', CommentsInSQL);
AssertFalse ('Aborted', Aborted);
AssertEquals ('Line', 0, Line);
AssertEquals ('Defines', 0, Defines.count);
AssertEquals ('Directives', 10, Directives.count);
end;
end;
procedure TTestSQLScript.TestTerminator;
begin
script.terminator := '!';
Add('doe!iets!');
Add('anders!');
script.execute;
AssertStatDir('doe,iets,anders', '');
end;
procedure TTestSQLScript.TestSetTerm;
begin
script.UseSetTerm:=true;
Add('SET TERM !;');
script.execute;
AssertEquals ('terminator', '!', script.terminator);
AssertStatDir('', '');
end;
procedure TTestSQLScript.TestUseSetTerm;
begin
script.UseSetTerm:=false;
Script.Directives.Add ('SET TERM');
Add('SET TERM !;');
script.execute;
AssertEquals ('terminator', ';', script.terminator);
AssertStatDir('', '"SET TERM(!)"');
end;
procedure TTestSQLScript.TestComments;
begin
script.CommentsInSQL := true;
Add('/* comment */');
Add('statement;');
script.execute;
AssertStatDir ('"/* comment */ statement"', '');
end;
procedure TTestSQLScript.TestUseComments;
begin
script.CommentsInSQL := false;
Add('/* comment */');
Add('statement;');
script.execute;
AssertStatDir ('statement', '');
end;
procedure TTestSQLScript.TestCommit;
begin
script.UseCommit := true;
Add('commit;');
script.execute;
AssertEquals ('Commits', 1, script.FCommits);
AssertStatDir ('', '');
end;
procedure TTestSQLScript.TestUseCommit;
begin
script.UseCommit := false;
with script.Directives do
Delete(IndexOf('COMMIT'));
Add('commit;');
script.execute;
AssertEquals ('Commits', 0, script.FCommits);
AssertStatDir ('commit', '');
end;
procedure TTestSQLScript.TestDefine;
begin
script.UseDefines := true;
Add ('#define iets;');
script.execute;
AssertStatDir ('', '');
AssertEquals ('Aantal defines', 1, script.defines.count);
AssertEquals ('Juiste define', 'iets', script.Defines[0]);
end;
procedure TTestSQLScript.TestUndefine;
begin
script.UseDefines := true;
script.defines.Add ('iets');
Add ('#undefine iets;');
script.execute;
AssertStatDir ('', '');
AssertEquals ('Aantal defines', 0, script.defines.count);
end;
procedure TTestSQLScript.TestUndef;
begin
script.UseDefines := true;
script.defines.Add ('iets');
Add ('#Undef iets;');
script.execute;
AssertStatDir ('', '');
AssertEquals ('Aantal defines', 0, script.defines.count);
end;
procedure TTestSQLScript.TestIfdef1;
begin
script.UseDefines := true;
script.defines.add ('iets');
Add('#ifdef iets;');
Add('doe iets;');
script.execute;
AssertStatDir('"doe iets"', '');
end;
procedure TTestSQLScript.TestIfdef2;
begin
script.UseDefines := true;
Add('#ifdef iets;');
Add('doe iets;');
script.execute;
AssertStatDir('', '');
end;
procedure TTestSQLScript.TestIfndef1;
begin
script.UseDefines := true;
Add('#ifndef iets;');
Add('doe iets;');
script.execute;
AssertStatDir('"doe iets"', '');
end;
procedure TTestSQLScript.TestIfndef2;
begin
script.UseDefines := true;
script.defines.add ('iets');
Add('#ifndef iets;');
Add('doe iets;');
script.execute;
AssertStatDir('', '');
end;
procedure TTestSQLScript.TestElse1;
begin
script.UseDefines := true;
script.defines.add ('iets');
Add('#ifdef iets;');
Add('doe iets;');
add('#else;');
add('anders;');
script.execute;
AssertStatDir('"doe iets"', '');
end;
procedure TTestSQLScript.TestElse2;
begin
script.UseDefines := true;
script.defines.add ('iets');
Add('#ifndef iets;');
Add('doe iets;');
add('#else;');
add('anders;');
script.execute;
AssertStatDir('anders', '');
end;
procedure TTestSQLScript.TestEndif1;
begin
script.UseDefines := true;
Add('#ifdef iets;');
Add('doe iets;');
add('#endif;');
add('anders;');
script.execute;
AssertStatDir('anders', '');
end;
procedure TTestSQLScript.TestEndif2;
begin
script.UseDefines := true;
Add('#ifndef iets;');
Add('doe iets;');
add('#endif;');
add('anders;');
script.execute;
AssertStatDir('"doe iets",anders', '');
end;
procedure TTestSQLScript.TestUseDefines;
begin
script.UseDefines := false;
Add('#ifndef iets;');
Add('doe iets;');
add('#endif;');
add('anders;');
script.execute;
AssertStatDir('"doe iets",anders', '#IFNDEF(iets),#ENDIF');
end;
procedure TTestSQLScript.TestTermInComment;
begin
script.CommentsInSQL := false;
Add('/* terminator ; */iets;');
script.execute;
AssertStatDir('iets', '');
end;
procedure TTestSQLScript.TestTermInQuotes1;
begin
script.CommentsInSQL := false;
Add('iets '';'';');
script.execute;
AssertStatDir('"iets '';''"', '');
end;
procedure TTestSQLScript.TestTermInQuotes2;
begin
script.CommentsInSQL := false;
Add('iets ";";');
script.execute;
AssertStatDir('"iets "";"""', '');
end;
procedure TTestSQLScript.TestCommentInComment;
begin
script.CommentsInSQL := false;
Add('/* meer /* */iets;');
script.execute;
AssertStatDir('iets', '');
end;
procedure TTestSQLScript.TestCommentInQuotes1;
begin
script.CommentsInSQL := false;
Add('iets ''/* meer */'';');
script.execute;
AssertStatDir('"iets ''/* meer */''"', '');
end;
procedure TTestSQLScript.TestCommentInQuotes2;
begin
script.CommentsInSQL := false;
Add('iets "/* meer */";');
script.execute;
AssertStatDir('"iets ""/* meer */"""', '');
end;
procedure TTestSQLScript.TestQuote1InComment;
begin
script.CommentsInSQL := false;
Add('/* s''morgens */iets;');
script.execute;
AssertStatDir('iets', '');
end;
procedure TTestSQLScript.TestQuote2InComment;
begin
script.CommentsInSQL := false;
Add('/* s"morgens */iets;');
script.execute;
AssertStatDir('iets', '');
end;
procedure TTestSQLScript.TestQuoteInQuotes1;
begin
script.CommentsInSQL := false;
Add('iets ''s"morgens'';');
script.execute;
AssertStatDir('"iets ''s""morgens''"', '');
end;
procedure TTestSQLScript.TestQuoteInQuotes2;
begin
script.CommentsInSQL := false;
Add('iets "s''morgens";');
script.execute;
AssertStatDir('"iets ""s''morgens"""', '');
end;
procedure TTestSQLScript.TestStatementStop;
begin
Add('END;meer;');
script.execute;
AssertStatDir('END', '');
end;
procedure TTestSQLScript.TestDirectiveStop;
begin
Add('Stop;meer;');
script.execute;
AssertStatDir('', 'STOP');
end;
procedure TTestSQLScript.TestStatementExeception;
begin
Add('iets;');
script.DoException:='FOUT';
AssertException (exception, @DoExecution);
AssertStatDir('iets', '');
end;
procedure TTestSQLScript.TestDirectiveException;
begin
Add('iets;');
script.Directives.Add('IETS');
script.DoException := 'FOUT';
AssertException (exception, @DoExecution);
AssertStatDir('', 'IETS');
end;
procedure TTestSQLScript.TestCommitException;
begin
Add ('commit;');
script.DoException := 'FOUT';
AssertException (exception, @DoExecution);
AssertStatDir('', '');
AssertEquals ('Commit count', 1, Script.FCommits);
end;
procedure TTestSQLScript.TestStatementOnExeception1;
begin
UseContinue := true;
script.DoException := 'Fout';
Add ('foutief;');
script.OnException:=@ExceptionHandler;
Script.Execute;
AssertEquals ('exception message', 'Fout', exceptionmessage);
AssertEquals ('exception statement', 'foutief', exceptionstatement);
end;
procedure TTestSQLScript.TestStatementOnExeception2;
begin
UseContinue := false;
script.DoException := 'Fout';
Add ('foutief;');
script.OnException:=@ExceptionHandler;
AssertException (exception, @DoExecution);
AssertEquals ('exception message', 'Fout', exceptionmessage);
AssertEquals ('exception statement', 'foutief', exceptionstatement);
end;
procedure TTestSQLScript.TestDirectiveOnException1;
begin
UseContinue := true;
script.DoException := 'Fout';
Add ('foutief;');
Script.Directives.Add ('FOUTIEF');
script.OnException:=@ExceptionHandler;
Script.Execute;
AssertEquals ('exception message', 'Fout', exceptionmessage);
AssertEquals ('exception statement', 'FOUTIEF', exceptionstatement);
end;
procedure TTestSQLScript.TestDirectiveOnException2;
begin
UseContinue := False;
script.DoException := 'Fout';
Add ('foutief;');
Script.Directives.Add ('FOUTIEF');
script.OnException:=@ExceptionHandler;
AssertException (exception, @DoExecution);
AssertEquals ('exception message', 'Fout', exceptionmessage);
AssertEquals ('exception statement', 'FOUTIEF', exceptionstatement);
end;
procedure TTestSQLScript.TestDirectiveOnException3;
begin
UseContinue := true;
script.DoException := 'Fout';
Add ('foutief probleem;');
Script.Directives.Add ('FOUTIEF');
script.OnException:=@ExceptionHandler;
Script.Execute;
AssertEquals ('exception message', 'Fout', exceptionmessage);
AssertEquals ('exception statement', 'FOUTIEF,probleem', exceptionstatement);
end;
procedure TTestSQLScript.TestCommitOnException1;
begin
UseContinue := true;
script.DoException := 'Fout';
Add ('Commit;');
script.OnException:=@ExceptionHandler;
Script.Execute;
AssertEquals ('exception message', 'Fout', exceptionmessage);
AssertEquals ('exception statement', 'COMMIT', exceptionstatement);
AssertEquals ('commit count', 1, Script.FCommits);
end;
procedure TTestSQLScript.TestCommitOnException2;
begin
UseContinue := false;
script.DoException := 'Fout';
Add ('Commit;');
script.OnException:=@ExceptionHandler;
AssertException (exception, @DoExecution);
AssertEquals ('exception message', 'Fout', exceptionmessage);
AssertEquals ('exception statement', 'COMMIT', exceptionstatement);
AssertEquals ('commit count', 1, Script.FCommits);
end;
{ TTestEventSQLScript }
procedure TTestEventSQLScript.Notify(Sender: TObject);
begin
inc (NotifyCount);
LastSender := Sender;
end;
procedure TTestEventSQLScript.NotifyStatement(Sender: TObject;
SQL_Statement: TStrings; var StopExecution: Boolean);
var r : integer;
s : string;
begin
StopExecution := StopToSend;
if SQL_Statement.count > 0 then
begin
s := SQL_Statement[0];
for r := 1 to SQL_Statement.count-1 do
s := s + ';' + SQL_Statement[r];
if SQL_Statement.count > 1 then
s := '"' + s + '"';
end
else
s := '';
if received <> '' then
received := received + ';' + s
else
received := s;
LastSender := Sender;
end;
procedure TTestEventSQLScript.NotifyDirective(Sender: TObject; Directive,
Argument: AnsiString; var StopExecution: Boolean);
var s : string;
begin
StopExecution := StopToSend;
if Argument = '' then
s := Directive
else
s := format ('%s(%s)', [Directive, Argument]);
if received <> '' then
received := received + ';' + s
else
received := s;
LastSender := Sender;
end;
procedure TTestEventSQLScript.SetUp;
begin
inherited SetUp;
Script := TEventSQLScript.Create (nil);
notifycount := 0;
Received := '';
LastSender := nil;
end;
procedure TTestEventSQLScript.TearDown;
begin
Script.Free;
inherited TearDown;
end;
procedure TTestEventSQLScript.TestStatement;
begin
StopToSend:=false;
Script.OnSQLStatement := @NotifyStatement;
Script.Script.Text := 'stat1;stat2;';
script.execute;
AssertEquals ('Received', 'stat1;stat2', received);
AssertSame ('Sender', script, LastSender);
end;
procedure TTestEventSQLScript.TestStatementStop;
begin
StopToSend:=true;
Script.OnSQLStatement := @NotifyStatement;
Script.Script.Text := 'stat1;stat2;';
script.execute;
AssertEquals ('Received', 'stat1', received);
AssertSame ('Sender', script, LastSender);
end;
procedure TTestEventSQLScript.TestDirective;
begin
StopToSend:=false;
Script.OnSQLStatement := @NotifyStatement;
Script.OnDirective := @NotifyDirective;
script.Directives.Add ('STAT1');
Script.Script.Text := 'stat1 ik;stat2;';
script.execute;
AssertEquals ('Received', 'STAT1(ik);stat2', received);
AssertSame ('Sender', script, LastSender);
end;
procedure TTestEventSQLScript.TestDirectiveStop;
begin
StopToSend:=true;
Script.OnSQLStatement := @NotifyStatement;
Script.OnDirective := @NotifyDirective;
script.Directives.Add ('STAT1');
Script.Script.Text := 'stat1 ik;stat2;';
script.execute;
AssertEquals ('Received', 'STAT1(ik)', received);
AssertSame ('Sender', script, LastSender);
end;
procedure TTestEventSQLScript.TestCommit;
begin
Script.OnCommit := @Notify;
Script.Script.Text := 'iets; commit; anders;';
script.execute;
AssertEquals ('NotifyCount', 1, NotifyCount);
AssertSame ('Sender', script, LastSender);
end;
procedure TTestEventSQLScript.TestBeforeExec;
begin
Script.BeforeExecute := @Notify;
Script.Script.Text := 'update iets; anders iets;';
script.execute;
AssertEquals ('NotifyCount', 1, NotifyCount);
AssertSame ('Sender', script, LastSender);
end;
procedure TTestEventSQLScript.TestAfterExec;
begin
Script.AfterExecute := @Notify;
Script.Script.Text := 'update iets; anders iets; en meer;';
script.execute;
AssertEquals ('NotifyCount', 1, NotifyCount);
AssertSame ('Sender', script, LastSender);
end;
initialization
RegisterTests ([TTestSQLScript, TTestEventSQLScript]);
end.
|