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.