2016-11-07 12:24:10 +01:00
|
|
|
unit TestCommonsU;
|
|
|
|
|
|
|
|
interface
|
|
|
|
|
|
|
|
uses
|
2017-08-20 02:36:22 +02:00
|
|
|
DUnitX.TestFramework;
|
2016-11-07 12:24:10 +01:00
|
|
|
|
|
|
|
type
|
|
|
|
TTestCommons = class(TTestCase)
|
|
|
|
private
|
|
|
|
FirstRec: Integer;
|
|
|
|
LastRec: Integer;
|
|
|
|
ExpectedFirstRec: Integer;
|
|
|
|
ExpectedLastRec: Integer;
|
|
|
|
Page: Integer;
|
|
|
|
|
|
|
|
published
|
|
|
|
procedure TestGetLimitByPagePage0;
|
|
|
|
procedure TestGetLimitByPagePage1;
|
|
|
|
procedure TestGetLimitByPagePage2;
|
|
|
|
procedure TestGetLimitByPagePage3;
|
|
|
|
end;
|
|
|
|
|
|
|
|
implementation
|
|
|
|
|
|
|
|
{ TTestCommons }
|
|
|
|
|
|
|
|
uses CommonsU;
|
|
|
|
|
|
|
|
procedure TTestCommons.TestGetLimitByPagePage0;
|
|
|
|
begin
|
|
|
|
Page := 0;
|
|
|
|
ExpectedException := EWrongPage;
|
|
|
|
GetLimitByPage(Page, FirstRec, LastRec);
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TTestCommons.TestGetLimitByPagePage1;
|
|
|
|
begin
|
|
|
|
Page := 1;
|
|
|
|
ExpectedFirstRec := 1;
|
|
|
|
ExpectedLastRec := 10;
|
|
|
|
GetLimitByPage(Page, FirstRec, LastRec);
|
|
|
|
CheckEquals(ExpectedFirstRec, FirstRec, 'FirstRec');
|
|
|
|
CheckEquals(ExpectedLastRec, LastRec, 'LastRec');
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TTestCommons.TestGetLimitByPagePage2;
|
|
|
|
begin
|
|
|
|
Page := 2;
|
|
|
|
ExpectedFirstRec := 11;
|
|
|
|
ExpectedLastRec := 20;
|
|
|
|
GetLimitByPage(Page, FirstRec, LastRec);
|
|
|
|
CheckEquals(ExpectedFirstRec, FirstRec, 'FirstRec');
|
|
|
|
CheckEquals(ExpectedLastRec, LastRec, 'LastRec');
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TTestCommons.TestGetLimitByPagePage3;
|
|
|
|
begin
|
|
|
|
Page := 3;
|
|
|
|
ExpectedFirstRec := 21;
|
|
|
|
ExpectedLastRec := 30;
|
|
|
|
GetLimitByPage(Page, FirstRec, LastRec);
|
|
|
|
CheckEquals(ExpectedFirstRec, FirstRec, 'FirstRec');
|
|
|
|
CheckEquals(ExpectedLastRec, LastRec, 'LastRec');
|
|
|
|
end;
|
|
|
|
|
|
|
|
initialization
|
|
|
|
|
|
|
|
// Register any test cases with the test runner
|
2017-08-20 02:36:22 +02:00
|
|
|
DUnitX.RegisterTestFixture(TTestCommons);
|
2016-11-07 12:24:10 +01:00
|
|
|
|
|
|
|
end.
|