Changeset 152 for trunk/Test.pas


Ignore:
Timestamp:
Jun 6, 2023, 5:05:18 PM (18 months ago)
Author:
chronos
Message:
  • Added: VCardProcessor class for processing contacts available from VCard package.
  • Added: Normalize menu action for normalization of contact property values.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Test.pas

    r149 r152  
    44
    55uses
    6   Classes, SysUtils, VCard, TestCase;
     6  Classes, SysUtils, VCard, VCardProcessor, TestCase;
    77
    88type
     
    2929  end;
    3030
     31  { TTestCaseVCardProcessor }
     32
     33  TTestCaseVCardProcessor = class(TTestCase)
     34    Input: string;
     35    Output: string;
     36    Processor: TVCardProcessor;
     37    procedure Run; override;
     38    constructor Create; override;
     39    destructor Destroy; override;
     40  end;
     41
    3142
    3243implementation
     
    3849  SExpected = 'Expected:';
    3950  SOutput = 'Output:';
     51
     52{ TTestCaseVCardProcessor }
     53
     54procedure TTestCaseVCardProcessor.Run;
     55var
     56  Lines: TStringList;
     57begin
     58  Lines := TStringList.Create;
     59  try
     60    with TVCardFile.Create(nil) do
     61    try
     62      Lines.Text := Input;
     63      VCard.LoadFromStrings(Lines);
     64
     65      Processor.Process(VCard);
     66
     67      Lines.Text := '';
     68      VCard.SaveToStrings(Lines);
     69      Evaluate(Lines.Text = Output);
     70      Log := SExpected + LineEnding +
     71        '"' + Output + '"' + LineEnding + LineEnding +
     72        SOutput + LineEnding +
     73        '"' + Lines.Text + '"';
     74    finally
     75      Free;
     76    end;
     77  finally
     78    Lines.Free;
     79  end;
     80end;
     81
     82constructor TTestCaseVCardProcessor.Create;
     83begin
     84  inherited;
     85  Processor := TVCardProcessor.Create(nil);
     86end;
     87
     88destructor TTestCaseVCardProcessor.Destroy;
     89begin
     90  FreeAndNil(Processor);
     91  inherited;
     92end;
    4093
    4194{ TTestCaseCheckProperty }
Note: See TracChangeset for help on using the changeset viewer.