source: trunk/TestCases.pas

Last change on this file was 143, checked in by chronos, 11 months ago

Removed U prefix from all units.

File size: 1.5 KB
Line 
1unit TestCases;
2
3interface
4
5uses
6 Classes, SysUtils, TestCase, Engine;
7
8type
9
10 { TTestCaseRun }
11
12 TTestCaseRun = class(TTestCase)
13 InitTrackCount: Integer;
14 Engine: TEngine;
15 procedure Run; override;
16 constructor Create; override;
17 destructor Destroy; override;
18 end;
19
20function InitTestCases: TTestCases;
21
22
23implementation
24
25function InitTestCases: TTestCases;
26begin
27 Result := TTestCases.Create;
28 with Result do begin
29 AddNew('Tick', TTestCaseRun);
30 with TTestCaseRun(AddNew('One track', TTestCaseRun)) do begin
31 InitTrackCount := 1;
32 end;
33 end;
34end;
35
36{ TTestCaseRun }
37
38procedure TTestCaseRun.Run;
39var
40 I: Integer;
41 MetroLine: TMetroLine;
42 UsedLines: Integer;
43begin
44 Engine.Map.Size := Point(640, 480);
45 Engine.View.DestRect := Rect(0, 0, 640, 480);
46 Engine.NewGame;
47 if InitTrackCount > 0 then begin
48 for I := 0 to InitTrackCount - 1 do begin
49 MetroLine := Engine.GetSelectedOrUnusedMetroLine;
50 MetroLine.ConnectStation(Engine.Stations[0], nil, nil);
51 MetroLine.ConnectStation(Engine.Stations[1], MetroLine.LineStations.Last, nil);
52 end;
53 UsedLines := 0;
54 for I := 0 to Engine.Lines.Count - 1 do
55 if Engine.Lines[I].LineStations.Count > 0 then Inc(UsedLines);
56 Evaluate(UsedLines = InitTrackCount);
57 Exit;
58 end;
59 for I := 0 to 100 do
60 Engine.Tick;
61 Pass;
62end;
63
64constructor TTestCaseRun.Create;
65begin
66 inherited;
67 Engine := TEngine.Create(nil);
68end;
69
70destructor TTestCaseRun.Destroy;
71begin
72 FreeAndNil(Engine);
73end;
74
75end.
76
Note: See TracBrowser for help on using the repository browser.