delphimvcframework/samples/outputcachewithredis/Test/TestCommonsU.pas
2017-08-19 20:36:22 -04:00

73 lines
1.5 KiB
ObjectPascal

unit TestCommonsU;
interface
uses
DUnitX.TestFramework;
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
DUnitX.RegisterTestFixture(TTestCommons);
end.