?????????????????????Щ????
???????????? ???????[ 2012/6/11 10:36:12 ] ????????
???????????????????????????????????????????????????Working Effectively with legacy Code ????????????1???????????????е????????????????н????????????????????????????????????????±???????????????????????????????????????RGHConnection????????????????????????????????????????α???RGHConnection?????CreditValidator?????????????????RGHConnection???????????????????????????
???????????????RGHConnection????е??????
RGHConnection
+ RGHConnection(port??name??password)
+ connect()
+ disconnect()
+RFDIReportFor(id:int):RFDIReport
+ACTIOReportFor(customerID:int) ACTIOReport
+retry()
+fromPacket():RFPacket
?????????RGHConnection?????Щ????????????????????????????????connect??disconnect???retry?????????Щ??????????????α?????RGHConnection??????????????α????????????????Щ???????????????????
????????Щ?????£?α?????RGHConnection????????????RGHConnection????y?????????????????????????????????????????????????????????????????????????????????
<interface>
IRGHConnection
+connect()
+ disconnect()
+RFDIReportFor(id:int):RFDIReport
+ACTIOReportFor(customerID:int) ACTIOReport
????????retry()??fromPacket()???????????????????????????????????????????????????????????????????????FackeConnection?????????????????????????????????????α??????????????У?
public class FakeConnection implements IRGHConnection
{
public RFDIReport report;
public void connect() {}
public void disconnnect(){}
public RFDIReport RFDReportFor(int id) {return report;}
public ACTIOReport ACTIOReportFor(int customerID) {return null;}
}
??????????????д????
void testNoSuccess()throws Exception{
CreditMaster master = new CreditMaster("crm2.mas"??true);
IRGHConnection connection = new FakeConnection();
CreditValidator validator = new CreditValidator(connection??master??"a");
connection.report = new RFDReport(....);
Certificate result = validator.validatorCustomer(new Customer(...));
assertEquals(Certificate.VALID??result.getStatus());
}
???????FakeConnection???????е???????????????????????????null?????????β?????????????????????????κ??????????????????????????????????????????????Υ???????е????????????????????????????????????????????ò?????е?????????????????FakeConnection?е????????????????????????????????е??????????????????????????????
???????????fake?????????????????????????????????????????????????????????????????????????????????????????ν?RGHConnection?????????????????????л???????????????????????????????????
??????

???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11