Reputation: 207
I have created a bunch of unit tests for my library which manipulate a certain .html file. What I want to do is back up the file before the tests and then restore it when the tests are over. I am using the AssemblyCleanup attribute for the restoration part, which works pretty well. The only problem is that when I stop the debugger manually, the clean up code is not executed and my file is not restored... Any advice?
Upvotes: 6
Views: 795
Reputation: 34285
You can't handle process termination from the process being terminated. Your only option is having another process which observes the terminated process.
Rearranging your code to do cleanup on startup would probably be a much easier option.
Upvotes: 4