unit TestmoduleData;
{

  Delphi DUnit Test Case
  ----------------------
  This unit contains a skeleton test case class generated by the Test Case Wizard.
  Modify the generated code to correctly setup and call the methods from the unit 
  being tested.

}

interface

uses
  TestFramework, FireDAC.Stan.Option, FireDAC.DApt.Intf, FireDAC.DatS,
  FireDAC.Stan.Def, FireDAC.FMXUI.Wait, FireDAC.Phys.SQLiteDef, System.SysUtils,
  System.Classes, FireDAC.Stan.Param, FireDAC.Stan.Intf, moduleData,
  FireDAC.Stan.Error, FireDAC.Phys.Intf, FireDAC.Comp.Client, FireDAC.VCLUI.Wait,
  FireDAC.Phys, FireDAC.Stan.Pool, FireDAC.Stan.ExprFuncs, FireDAC.Stan.Async,
  FireDAC.DApt, untCard, FireDAC.Phys.SQLite, Data.DB, FireDAC.UI.Intf,
  FireDAC.Comp.DataSet, FireDAC.Phys.SQLiteWrapper.Stat;

type
  // Test methods for class TDMData

  TestTDMData = class(TTestCase)
  strict private
    FDMData: TDMData;
  public
    procedure SetUp; override;
    procedure TearDown; override;
  published
    procedure TestDataModuleCreate;
    procedure TestDataModuleDestroy;
    procedure TestSearchCards;
    procedure TestGetCards;
    procedure TestGetCardName;
    procedure TestGetCardInfo;
  end;

implementation

uses
  untArrayHelper;

procedure TestTDMData.SetUp;
begin
  FDMData := TDMData.Create(nil);
end;

procedure TestTDMData.TearDown;
begin
  FDMData.Free;
  FDMData := nil;
end;

procedure TestTDMData.TestDataModuleCreate;
var
  Sender: TObject;
begin
  // TODO: Setup method call parameters
  FDMData.DataModuleCreate(Sender);
  // TODO: Validate method results
end;

procedure TestTDMData.TestDataModuleDestroy;
var
  Sender: TObject;
begin
  // TODO: Setup method call parameters
  FDMData.DataModuleDestroy(Sender);
  // TODO: Validate method results
end;

procedure TestTDMData.TestSearchCards;
var
  ReturnValue: TArray<ICard>;
  keyword: string;
  i: Integer;
begin
  Writeln('TestSearchCards');
  keyword := '百夫';
  // TODO: Setup method call parameters
  ReturnValue := FDMData.SearchCards(keyword);
  // TODO: Validate method results
  for i := 0 to ReturnValue.Count - 1 do begin
    Writeln(ReturnValue[i].GetCardName);
  end;
end;

procedure TestTDMData.TestGetCards;
var
  ReturnValue: TArray<ICard>;
  list: TArray<Int64>;
  i: Integer;
begin
  Writeln('TestGetCards');
  list := ArrayOfInt64([2511, 10000, 27551]);
  // TODO: Setup method call parameters
  ReturnValue := FDMData.GetCards(list);
  // TODO: Validate method results
  for i := 0 to ReturnValue.Count - 1 do begin
    Writeln(ReturnValue[i].GetCardName);
  end;
end;

procedure TestTDMData.TestGetCardName;
var
  ReturnValue: string;
  cardId: Int64;
begin
  Writeln('TestGetCardName');
  cardId := 10000;
  // TODO: Setup method call parameters
  ReturnValue := FDMData.GetCardName(cardId);
  // TODO: Validate method results
  Writeln(ReturnValue);
end;

procedure TestTDMData.TestGetCardInfo;
var
  ReturnValue: ICard;
  cardId: Int64;
begin
  Writeln('TestGetCardInfo');
  cardId := 10000;
  // TODO: Setup method call parameters
  ReturnValue := FDMData.GetCardInfo(cardId);
  // TODO: Validate method results
  Writeln(ReturnValue.GetCardName);
end;

initialization
  // Register any test cases with the test runner
  // RegisterTest(TestTDMData.Suite);
end.

