How can I write a unit test for a method that has a using statement?
For example let assume that I have a method
public bool Foo()
using (IMyDisposableClass client = new MyDisposableClass())
If you construct the
IMyDisposableClass using a factory (injected into the parent class) rather than using the new keyword, you can mock the
IMyDisposable and do a verify on the dispose method call.