uTestRuleMgr.pas
上传用户:yjb1804
上传日期:2021-01-30
资源大小:3105k
文件大小:3k
- unit uTestRuleMgr;
- interface
- uses
- TestFrameWork,uRulerMgr,StrUtils,SysUtils;
- type
- TTestCaseRulerMgr = class(TTestCase)
- private
- FRI,FClone:TRuleItems;
- public
- procedure Setup; override ;
- procedure TearDown; override;
- published
- procedure TestReadFromFile;
- procedure TestNameEqu;
- procedure TestRowsCountEqu;
- procedure TestRowContent;
- end;
- implementation
- { TTestCaseFirst }
- procedure TTestCaseRulerMgr.Setup;
- begin
- FRI:=TRuleItems.Create;
- with FRI.Add do
- begin
- Name:='add1';
- with Rows.Add do
- begin
- Text:='text1';
- Compare:=rcContains;
- Area:=raSubject;
- end;
- RulerAction.DeleteOnServer:=True;
- end;
- with FRI.Add do
- begin
- Name:='add2';
- Account:='Account2';
- with Rows.Add do
- begin
- Text:='text2_1';
- Compare:=rcContains;
- Area:=raTo;
- end;
- with Rows.Add do
- begin
- Text:='text2_2';
- Compare:=rcEquals;
- Area:=raTo;
- end;
- RulerAction.PlaySound:='PlaySound2';
- end;
- FClone:=TRuleItems.Create;
- FClone.Assign(FRI);
- end;
- procedure TTestCaseRulerMgr.TearDown;
- begin
- FClone.free;
- FRI.Free;
- end;
- procedure TTestCaseRulerMgr.TestNameEqu;
- begin
- check((FRI.Items[0].Name=FClone.Items[0].Name) and (FRI.Items[1].Name=FClone.Items[1].Name) ,'名字不相同' ) ;
- end;
- procedure TTestCaseRulerMgr.TestReadFromFile;
- var
- r,x:TRuleItems;
- S:string;
- begin
- r:=TRuleItems.Create;
- with r.Add do
- begin
- Name:='add1';
- RulerAction:=TRuleAction.Create;
- RulerAction.PlaySound:='playsound';
- RulerAction.RunExe:='Runexepath';
- Rows:=TRuleRows.Create;
- with Rows.Add do
- begin
- Area:=raHeader;
- Text:='rowstext1';
- end;
- with Rows.Add do
- begin
- Area:=raFrom;
- Text:='rowstext2';
- end;
- end;
- r.SaveToFile('E:1.xml');
- r.Free;
- x:=TRuleItems.Create;
- TRuleItems.ReadFromFile('E:1.xml',X);
- S:='x.Items[0]).Rows.Count: '+IntToStr(TRuleItem(x.Items[0]).Rows.Count)+#13#10;
- S:=S+'Text1: '+TRuleRow(TRuleItem(x.Items[0]).Rows.Items[0]).Text+#13#10;
- S:=S+'Text2: '+TRuleRow(TRuleItem(x.Items[0]).Rows.Items[1]).Text+#13#10;
- S:=S+'Values must be 2,rowstext1,rowstext2';
- Status(S);
- x.Free;
- end;
- procedure TTestCaseRulerMgr.TestRowContent;
- begin
- CheckEqualsString('text2_1',FClone.Items[1].Rows[0].Text,'FClone.Items[1].Rows[0].Text');
- end;
- procedure TTestCaseRulerMgr.TestRowsCountEqu;
- begin
- CheckEquals(2,FClone.Items[1].Rows.Count,'FClone.Items[1].Rows.Count');
- end;
- initialization
- TestFramework.RegisterTest(TTestCaseRulerMgr.Suite);
- end.