1
votes

I have inherited an ASP.Net c# application which I must now maintain; the application was developed a while ago and, although the code works, it is all mixed together (business logic and MySQL data access code in the various classes), and no unit tests have been done. Also, a lot of business logic is in the web forms themselves.

Obviously this situation makes it hard to maintain and improve, so I am trying to start refactoring the code. I want to do this under tests, so I must start developing some unit tests under VS2010. I am wondering whether it is best to start separating the code and then write the tests or write the tests first. I really don't know where to start, so any advise you may furnish on this issue will be greatly appreciated.

1
The Software Vice pattern is probably a very useful start to allow you to refactor with more confidence: lostechies.com/seanchambers/2009/04/22/vice-testing - jessehouwing

1 Answers

0
votes

Check out the MVP design pattern. You can also make use of the Repository pattern to create testable code. I recommend using Moq to mock your interfaces. There are resources on the web, but unfortunately I can't go into more detail without writing an entire article.