unit TestuDirectories_TPS_ChunkUploader;
{

  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, System.Classes, uDirectories_TPS_ChunkUploader,
  uCreateUniqueName_TPS_ChunkUploader, System.SysUtils,System.IOUtils,

  //myUnits
  uMain_TPS_ChunkUploader
  ;

type
  // Test methods for class TDirectories_TPS_ChunkUploader

  TestTDirectories_TPS_ChunkUploader = class(TTestCase)
  strict private

    FPS_ChunkUploader:TPS_ChunkUploader;
    FDirectories_TPS_ChunkUploader: TDirectories_TPS_ChunkUploader;


  public
    procedure SetUp; override;
    procedure TearDown; override;
  published
    procedure TestCreateOutputDirOnServer();
    procedure TestCreateTempDirOnServer();
    procedure TestCreateTempDirOnClient();
  end;

implementation

procedure TestTDirectories_TPS_ChunkUploader.SetUp;
begin

    FPS_ChunkUploader:=TPS_ChunkUploader.Create(nil);

   with FPS_ChunkUploader.VisualFrame_TPS_ChunkUploader do begin


      with HTTP_ConnectionParams do begin

      Protocol:='http';
      Host:='localhost';//'40.85.142.196';//'192.168.1.102';//'localhost';
      Port:='40000';
      IdUser:='1'; // << Critical important to use ID that are in DataBase coffeetest.users
      User:='SomeUser';

      DefineServerToRequest();

      end;



 end;


  FDirectories_TPS_ChunkUploader :=
  TDirectories_TPS_ChunkUploader.Create(FPS_ChunkUploader.VisualFrame_TPS_ChunkUploader);

end;



procedure TestTDirectories_TPS_ChunkUploader.TearDown;
begin

  FDirectories_TPS_ChunkUploader.Free;
  FDirectories_TPS_ChunkUploader := nil;

  FPS_ChunkUploader.Free();
  FPS_ChunkUploader:=nil;

end;


procedure TestTDirectories_TPS_ChunkUploader.TestCreateOutputDirOnServer;
var
  ReturnValue: string;
begin

  FDirectories_TPS_ChunkUploader.CreateUniqueNameFromOriginName();
  ReturnValue := FDirectories_TPS_ChunkUploader.CreateOutputDirOnServer;
  // TODO: Validate method results

  CheckNotEquals('',ReturnValue,'Failed CreateOutputDirOnServer ');
  Status('Success');

end;


procedure TestTDirectories_TPS_ChunkUploader.TestCreateTempDirOnClient();
var ReturnValue:string;
begin
//

FDirectories_TPS_ChunkUploader.OriginFileName:='SomeFileName';

FDirectories_TPS_ChunkUploader.CreateUniqueNameFromOriginName();
ReturnValue := FDirectories_TPS_ChunkUploader.CreateTempDirOnClient();

CheckNotEquals('',ReturnValue,'Failed CreateOutputDirOnServer ');
Status('Success');

if ReturnValue<>''
then TDirectory.Delete(FDirectories_TPS_ChunkUploader.TempDirOnClient,true);


end;

procedure TestTDirectories_TPS_ChunkUploader.TestCreateTempDirOnServer;
var
  ReturnValue: string;
begin

  FDirectories_TPS_ChunkUploader.CreateUniqueNameFromOriginName();
  ReturnValue := FDirectories_TPS_ChunkUploader.CreateTempDirOnServer();
  // TODO: Validate method results

  CheckNotEquals('',ReturnValue,'Failed CreateTempDirOnServer ');
  Status('Success');

end;

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

