.NET????????????????1??
???????????? ???????[ 2013/10/9 13:47:19 ] ????????
????1?????????
????????????????????Sprint??????ε??????????Щ???????????????????????????????????????
???????????????????????????????????????????????????????????????????????????????????????ò????????????????????????????????е???????????????????????????????????д???????????????????????д??????????????????????????????????????????????????????????????£??????????????????????????????????????????????????????????????????????к????????????????????????е??????????????????????????????·???????????????????????·??????·??
????????????д???????????????????????????????????????????????????????????????????????????????????????ж?????????д???????????????????????????????????棻???磺Order.ToString()??????????????????????????????????????????????????????в???????NULL??????μ????????????????????????????????BUG?????·????????????????????д???????????????Ч????
?????????????????????о?????????????????????????????????????????????????????????????????
????2?????????????????????????????????????????Mock?????????????
???????????????г??????????Mock????Fake?????????????????????????????????????л??????????????Mock?????????????????????????д????????Ч??????????????????????????????????????????
??????????????????????????????????????????????????????????????????????????????????ж?????????????????????????????????????裬????????????????????Mock???????????????????????????????????????仯?????????????????????????????????????????
?????????????????????????????????????????????????????????????????y????????????????У?
????2.1????????????????????ó?????????Mock?????????
??????????????????????????????????????????????????????????????????????????????????????????????????乲???????????????????????????????У?????????????????????????????????Щ???????????????
?????????????????????Mock?????????????????????Mock????????????????????????????о?????????????????????????????????????????????????????????????????????У??????Mock?????????????????????????????Mock????????
??????????????????????????????????????? ????????????????????????????????????????????????
????2.1.1???????Mock????
??????????????????????Mock??????????????????????????????????????й???????????????????????????????
????????????????е???y????????????У???????????????
????????????????????y????????????????????????????????????????
????????????????μ?????????????2??????????
namespace UnitTestRefactoring { public class OrderService { private IServiceConnection ServiceConnection; private IServiceReader ServiceReader; private IServiceWriter ServiceWrite; public OrderService(IServiceConnection connection?? IServiceReader reader?? IServiceWriter writer) { this.ServiceConnection = connection; this.ServiceReader = reader; this.ServiceWrite = writer; } public bool GetOrders(string orderId) { if (string.IsNullOrWhiteSpace(orderId)) return false; return true; } } } <STRONG> </STRONG> |
namespace UnitTestRefactoring { public class OrderService { private IServiceConnection ServiceConnection; private IServiceReader ServiceReader; private IServiceWriter ServiceWrite; public OrderService(IServiceConnection connection?? IServiceReader reader?? IServiceWriter writer) { this.ServiceConnection = connection; this.ServiceReader = reader; this.ServiceWrite = writer; } public bool GetOrders(string orderId) { if (string.IsNullOrWhiteSpace(orderId)) return false; return true; } } } |
??????
???·???
??????????????????
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