Re: How do I unit test a Dispose method ?
Gishu Pillai <[email protected]> Thu, 23 Jan 2014 16:36:46 +0530
| Newsgroups | gmane.comp.programming.test-driven-development |
|---|---|
| Message-ID | <CABT02tsSSqGkgZWESqazVeA6JTS19XQzHRNxcNWJZXff_P0N0A@mail.gmail.com> |
public Connection(SecureString password)
{
_myPassword = password.Copy(); // creates a clone of the password which
needs to be disposed
}
public void Dispose()
{
_myPassword.Dispose(); // releases any resources it holds
}
SecureString is a .Net framework type. I could wrap it in an adapter to
ease testing...but doesn't solve the general problem. Wrapping all member
disposable type with interfaces is going to be tedious.
It seems this is a better fit for Static code analysis.
Gishu