???????????α??????е??????
???????????? ???????[ 2012/9/18 10:58:39 ] ????????
??????????????
????1????д?????????????????
????д??????????????????????????????????????????????????????????????????????????????????壬???????????д?????????????????????????????
??????1?????д???????????????N??α??????TMD??????????д????????д????????
??????2????Щ?????????????????????????????????????к????з?????д????????д????????
??????3???Щ??????????????????????д???????????????????д????????д????????
??????4????????????????ε????????漰???????????????????д??????д????????д????????
??????5??д??????????????????????????????????TMD???д??飬д????????д????????
???????????????????????????д????????????????????????????д?????????????????????????????????????????????????????????????????????????????????д??????????????á?
????????ó????????д???е????????e???????????????????????????????????????????????????????????????????????????????????????????...
???????????????????????ж??????????????д???????????Ψ???????
????2??????????
?????????????е????????????????????Rhino Mocks(????????????)???????????????????????????????????????е???????
??????1???????????LogService
var mock = new Rhino.Mocks.MockRepository(); var logService = mock.Stub<ILogService>(); CurrentFileMonitor.LogService = logService; Assert.IsNotNull(CurrentFileMonitor.LogService?? "ConfigFileMonitor stub LogService is not initialized"); |
??????2????????????EmailService
var mock = new Rhino.Mocks.MockRepository(); var emailService = mock.DynamicMock<IEmailService>(); CurrentFileMonitor.EmailService = emailService; Assert.IsNotNull(CurrentFileMonitor.EmailService?? "ConfigFileMonitor mock EmailService is not initialized"); |
??????3?????????
????a??????????-??????
/// <summary>
var shortFileName = "abc.txt";
mock.Verify(emailService);//VerifyAll()????Verify(stub)?????????????κζ????????????????????? |
????b??????-????-????(AAA)???
/// <summary>
var emailService = mock.DynamicMock<IEmailService>(); mock.ReplayAll(); //?????????
var shortFileName = "abc.txt";
//???Rhino Mocks?????? |
?????????????????-?????????AAA??Arrange-Act-Assert????????-????-????????????Rhino Mocks????α??????в??????????????????????AAA?????????У?д???????????????????????С???????????????????????demo????????
???????????????????????Moq??Typemock Isolator??EasyMock.NET??NMock??NUnit.Mocks??????Moq????????????????????????????ο????Щ??????????????Щд??????Rhino Mocks?????????????????Moq?????AAAд????Rhino Mocks??????????????AAA??????Moq??????????ο?????????
?????????????????£?????и????????????????????????н??е???????????????????????????????????????????????????????????????????????а???????????????????????????????????????????????????????????????????????????д?????????????????????????????????????????????????????
??????
???·???
??????????????????
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