RE: How to use TDD to test a process?
"'Donaldson, John' [email protected] [testdrivendevelopment]" <[email protected]> Mon, 25 Apr 2016 15:48:13 +0000
| Newsgroups | gmane.comp.programming.test-driven-development |
|---|---|
| Message-ID | <716D07F3CBA94244A0922E7A99837C3A2FF25894@G4W3228.americas.hpqcorp.net> |
Sailor.gao, your question is not very clear. I suppose you want to know if method Record actually calls GetUser then Delete or Save? So, either you reason by the side effects (such as the record has gone from the database), or you use a mock of some kind to show you call the expected methods in the expected order. John D. From: [email protected] [mailto:[email protected]] Sent: 25 April 2016 14:37 To: [email protected] Subject: [TDD] How to use TDD to test a process? I try to use stub but it seems not very good. I want to know how should I write the test case, and how many should it be? Could someone help me? Thank U! logic like this: public class User { public int ID { get;set; } public String Name { get;set; } public String BrokerID { get;set; } public String Timestamp { get;set; } } public interface IUserDao { User GetUser(string userID,string brokerID); bool Save(User user); bool Delete(User user); } public UserService { private IUserDao _userDao; public UserService(IUserDao userDao) { _userDao=userDao; } public bool Record(User user) { User origin=_userDao.GetUser(user.Name,user.BrokerID); if(orign) { if(!_userDao.Delete(origin)) { return false; } } if(!_userDao.Save(user)) { return false; } ; return true; } } [Non-text portions of this message have been removed] ------------------------------------ Posted by: "Donaldson, John" <[email protected]> ------------------------------------