Changeset 146 for trunk/UTest.pas


Ignore:
Timestamp:
Aug 30, 2022, 7:56:17 PM (2 years ago)
Author:
chronos
Message:
  • Modified: General test part moved into Common package.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/UTest.pas

    r138 r146  
    44
    55uses
    6   Classes, SysUtils, Generics.Collections, UVCard;
     6  Classes, SysUtils, Generics.Collections, UVCard, UTestCase;
    77
    88type
    9   TTestResult = (trNone, trPassed, trFailed);
    10 
    11   { TTestCase }
    12 
    13   TTestCase = class
    14   public
    15     Name: string;
    16     Result: TTestResult;
    17     Log: string;
    18     procedure Run; virtual;
    19     procedure Evaluate(Passed: Boolean);
    20     procedure Pass;
    21     procedure Fail;
    22   end;
    23 
    24   TTestCaseClass = class of TTestCase;
    25 
    26   { TTestCases }
    27 
    28   TTestCases = class(TObjectList<TTestCase>)
    29     function AddNew(Name: string; TestClass: TTestCaseClass): TTestCase;
    30   end;
    319
    3210  TTestCaseActionKind = (akNone, akRemoveExactDuplicates);
     
    5129  end;
    5230
    53 resourcestring
    54   SNone = 'None';
    55   SPassed = 'Passed';
    56   SFailed = 'Failed';
    57 
    58 const
    59   ResultText: array[TTestResult] of string = (SNone, SPassed, SFailed);
    60 
    61 procedure Translate;
    62 
    6331
    6432implementation
     
    7038  SExpected = 'Expected:';
    7139  SOutput = 'Output:';
    72 
    73 procedure Translate;
    74 begin
    75   ResultText[trNone] := SNone;
    76   ResultText[trPassed] := SPassed;
    77   ResultText[trFailed] := SFailed;
    78 end;
    7940
    8041{ TTestCaseCheckProperty }
     
    13899end;
    139100
    140 { TTestCase }
    141 
    142 procedure TTestCase.Run;
    143 begin
    144 end;
    145 
    146 procedure TTestCase.Evaluate(Passed: Boolean);
    147 begin
    148   if Passed then Result := trPassed
    149     else Result := trFailed;
    150 end;
    151 
    152 procedure TTestCase.Pass;
    153 begin
    154   Result := trPassed;
    155 end;
    156 
    157 procedure TTestCase.Fail;
    158 begin
    159   Result := trFailed;
    160 end;
    161 
    162 { TTestCases }
    163 
    164 function TTestCases.AddNew(Name: string; TestClass: TTestCaseClass): TTestCase;
    165 begin
    166   Result := TestClass.Create;
    167   Result.Name := Name;
    168   Add(Result);
    169 end;
    170 
    171101end.
    172102
Note: See TracChangeset for help on using the changeset viewer.