unit TestuntCard;
{

  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, Classes, Generics.Collections, untCard, SysUtils;

type
  // Test methods for class TCard

  TestTCard = class(TTestCase)
  strict private
    FCard: TCard;
  public
    procedure SetUp; override;
    procedure TearDown; override;
  published
    procedure Test;
  end;
  // Test methods for class TPuzzleField

  TestTPuzzleField = class(TTestCase)
  strict private
    FPuzzleField: TPuzzleField;
  public
    procedure SetUp; override;
    procedure TearDown; override;
  published
    procedure TestFindCard;
    procedure TestGetCardByFieldRec;
    procedure TestOptimize;
  end;

implementation

uses
  untArrayHelper;

procedure TestTCard.SetUp;
var
  c1, c2, c3: ICard;
  cards: TArray<ICard>;
begin
  Writeln('TestTCard.SetUp');
  FCard := TCard.Create;
  c1 := TCard.Create;
  c1.SetCardId(1);
  c2 := TCard.Create;
  c2.SetCardId(2);
  c3 := TCard.Create;
  c3.SetCardId(3);
  SetLength(cards, 2);
  cards[0] := c1;
  cards[1] := c2;
  FCard.ContinousEffectTo := cards;
  FCard.SetEquipTo(c3);
end;

procedure TestTCard.TearDown;
begin
  Writeln('TestTCard.TearDown');
  FCard.Free;
  FCard := nil;
end;

procedure TestTCard.Test;
var
  i: Integer;
  len: Integer;
  c: ICard;
begin
  len := Length(FCard.ContinousEffectTo);
  for i := 0 to len - 1 do begin
    c := FCard.ContinousEffectTo[i];
    Writeln(Format('card id = %d', [c.GetCardId]));
  end;
  Writeln(FCard.GetEquipTo.GetCardId);
end;

procedure TestTPuzzleField.SetUp;
var
  c1, c2: ICard;
begin
  FPuzzleField := TPuzzleField.Create;
  c1 := TCard.Create;
  c1.SetCardId(1);
  c2 := TCard.Create;
  c2.SetCardId(2);

  FPuzzleField.P0Hand := ArrayOfCard([c1, c2]);
end;

procedure TestTPuzzleField.TearDown;
begin
  FPuzzleField.Free;
  FPuzzleField := nil;
end;

procedure TestTPuzzleField.TestFindCard;
var
  ReturnValue: Boolean;
  ACard: TCard;
  i: Integer;
begin
  Writeln(FPuzzleField.P0Hand.Count);
  for i := 0 to FPuzzleField.P0Hand.Count - 1 do begin
    Writeln(Format('Hand Card Id = %d', [FPuzzleField.P0Hand[i].GetCardId]));
  end;
  // TODO: Setup method call parameters
  // ReturnValue := FPuzzleField.FindCard(ACard);
  // TODO: Validate method results
end;

procedure TestTPuzzleField.TestGetCardByFieldRec;
var
  ReturnValue: TCard;
  fr: TFieldRec;
begin
  // TODO: Setup method call parameters
  // ReturnValue := FPuzzleField.GetCardByFieldRec(fr);
  // TODO: Validate method results
end;

procedure TestTPuzzleField.TestOptimize;
begin
  FPuzzleField.Optimize;
  // TODO: Validate method results
end;

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

