@@ -38,6 +38,11 @@ interface
3838 test_miscellaneous;
3939
4040type
41+ TConsoleLogData = record
42+ StatusOK: boolean;
43+ TorrentFilesCount: integer;
44+ TrackersCount: integer;
45+ end ;
4146
4247 { TTestStartUpParameter }
4348
@@ -53,7 +58,9 @@ TTestStartUpParameter = class(TTestCase)
5358 FVerifyTrackerResult: TVerifyTrackerResult;
5459 FExitCode: integer;
5560 FCommandLine: string;
61+ FConsoleLogData: TConsoleLogData;
5662
63+ function ReadConsoleLogFile : boolean;
5764 procedure TestParameter (TrackerListOrder: TTrackerListOrder);
5865 procedure DownloadPreTestTrackerList ;
5966 procedure LoadTrackerListAddAndRemoved ;
@@ -69,10 +76,8 @@ TTestStartUpParameter = class(TTestCase)
6976 procedure SetUp ; override;
7077 procedure TearDown ; override;
7178 published
72- procedure Test_Create_Empty_DHT_torrent ;
7379 procedure Test_Tracker_UserInput_Without_Announce_Exit_Code ;
74- procedure Test_Create_Simple_Filled_torrent ;
75- procedure Test_Create_Filled_And_Empty_Torrent_All_Mode ;
80+ procedure Test_Create_Empty_Torrent_And_Then_Filled_It_All_Mode ;
7681
7782 procedure Test_Paramater_U0 ;
7883 procedure Test_Paramater_U1 ;
@@ -94,6 +99,9 @@ implementation
9499 TORRENT_FOLDER = ' test_torrent' ;
95100 END_USER_FOLDER = ' enduser' ;
96101
102+ // there are 3 test torrent files in 'test_torrent' folder.
103+ TEST_TORRENT_FILES_COUNT = 3 ;
104+
97105procedure TTestStartUpParameter.Test_Paramater_U0 ;
98106begin
99107 Test_Paramater_Ux(tloInsertNewBeforeAndKeepNewIntact);
@@ -295,22 +303,15 @@ procedure TTestStartUpParameter.Test_Paramater_Ux(TrackerListOrder: TTrackerList
295303
296304 // check the exit code
297305 CheckEquals(0 , FExitCode);
298- end ;
299306
300- procedure TTestStartUpParameter.Test_Create_Empty_DHT_torrent ;
301- var
302- TrackerListOrder: TTrackerListOrder;
303- begin
304- // Test if all the tracker update mode is working
305- for TrackerListOrder in TTrackerListOrder do
306- begin
307- CreateEmptyTorrent(TrackerListOrder);
308- TestEmptyTorrentResult;
309- // check the exit code
310- CheckEquals(0 , FExitCode);
311- end ;
307+ // Check the logdata status
308+ Check(ReadConsoleLogFile, ' Log data is not present' );
309+ Check(FConsoleLogData.StatusOK);
310+ Check(FConsoleLogData.TrackersCount > 0 );
311+ Check(FConsoleLogData.TorrentFilesCount = TEST_TORRENT_FILES_COUNT);
312312end ;
313313
314+
314315procedure TTestStartUpParameter.Test_Tracker_UserInput_Without_Announce_Exit_Code ;
315316var
316317 TrackerListOrder: TTrackerListOrder;
@@ -334,42 +335,72 @@ procedure TTestStartUpParameter.Test_Tracker_UserInput_Without_Announce_Exit_Cod
334335
335336 // check the exit code. Must be an error
336337 CheckNotEquals(0 , FExitCode);
338+
339+ // Check the logdata status
340+ Check(ReadConsoleLogFile, ' Log data is not present' );
341+ // the result must be false
342+ CheckFalse(FConsoleLogData.StatusOK);
337343 end ;
338344end ;
339345
340- procedure TTestStartUpParameter.Test_Create_Simple_Filled_torrent ;
341- begin
342- CreateFilledTorrent(tloInsertNewBeforeAndKeepNewIntact);
343-
344- // check the exit code
345- CheckEquals(0 , FExitCode);
346- end ;
347346
348- procedure TTestStartUpParameter.Test_Create_Filled_And_Empty_Torrent_All_Mode ;
347+ procedure TTestStartUpParameter.Test_Create_Empty_Torrent_And_Then_Filled_It_All_Mode ;
349348var
350349 TrackerListOrder: TTrackerListOrder;
351350begin
352351 // Test if all the mode that support empty torrent creation
352+ // Empty torrent -> filled torrent -> empty torrent
353+
353354 for TrackerListOrder in TTrackerListOrder do
354355 begin
355356
356- // todo: Is this by design that empty torrent is here rejected?
357+ // It is by design that it can not create a empty torrent
358+ // The 'KeepOriginalIntactAndRemoveNothing' prevent it from deleting the torrent
359+ // must skip the test for this one
357360 if TrackerListOrder = tloInsertNewBeforeAndKeepOriginalIntactAndRemoveNothing then
358361 continue;
359362
360- // todo: Is this by design that empty torrent is here rejected?
363+ // It is by design that it can not create a empty torrent
364+ // The 'KeepOriginalIntactAndRemoveNothing' prevent it from deleting the torrent
365+ // must skip the test for this one
361366 if TrackerListOrder = tloAppendNewAfterAndKeepOriginalIntactAndRemoveNothing then
362367 continue;
363368
369+ // Create empty the torrent
364370 CreateEmptyTorrent(TrackerListOrder);
365371 // check the exit code
366372 CheckEquals(0 , FExitCode);
367373
368374 TestEmptyTorrentResult;
375+ // Check the logdata status
376+ Check(ReadConsoleLogFile, ' Log data is not present' );
377+ Check(FConsoleLogData.StatusOK);
378+ Check(FConsoleLogData.TrackersCount = 0 );
379+ Check(FConsoleLogData.TorrentFilesCount = TEST_TORRENT_FILES_COUNT);
369380
381+ // fill the empty torrent with data
370382 CreateFilledTorrent(TrackerListOrder);
371383 // check the exit code
372384 CheckEquals(0 , FExitCode);
385+
386+ // Check the logdata status
387+ Check(ReadConsoleLogFile, ' Log data is not present' );
388+ Check(FConsoleLogData.StatusOK);
389+ Check(FConsoleLogData.TrackersCount > 0 );
390+ Check(FConsoleLogData.TorrentFilesCount = TEST_TORRENT_FILES_COUNT);
391+
392+ // Create empty the torrent again
393+ CreateEmptyTorrent(TrackerListOrder);
394+ // check the exit code
395+ CheckEquals(0 , FExitCode);
396+
397+ TestEmptyTorrentResult;
398+ // Check the log data status
399+ Check(ReadConsoleLogFile, ' Log data is not present' );
400+ Check(FConsoleLogData.StatusOK);
401+ Check(FConsoleLogData.TrackersCount = 0 );
402+ Check(FConsoleLogData.TorrentFilesCount = TEST_TORRENT_FILES_COUNT);
403+
373404 end ;
374405end ;
375406
@@ -418,6 +449,12 @@ procedure TTestStartUpParameter.TearDown;
418449 FNewTrackon.Free;
419450end ;
420451
452+ function TTestStartUpParameter.ReadConsoleLogFile : boolean;
453+ begin
454+ Result := LoadConsoleLog(FFullPathToEndUser + FILE_NAME_CONSOLE_LOG,
455+ FConsoleLogData.StatusOK, FConsoleLogData.TorrentFilesCount,
456+ FConsoleLogData.TrackersCount);
457+ end ;
421458
422459initialization
423460
0 commit comments