Keyboard Shortcuts
Likes
Search
[TDD] How do I unit test a Dispose method ?
Donaldson, John
¿ªÔÆÌåÓýGishu, ? Could you inject a mocked SecureString? Then you can check if the SecureString.Dispose is called. Seems like a good place to use a mock as it¡¯s a ¡°tell¡± pattern. ? John D. ? From: testdrivendevelopment@... [mailto:testdrivendevelopment@...]
On Behalf Of Gishu Pillai
Sent: 23 January 2014 08:26 To: testdrivendevelopment@... Subject: [TDD] How do I unit test a Dispose method ? ?
The question is a bit .Net specific. class Connection ?? private SecureString password; } SecureString is Disposable. That mandates that Connection should have a Dispose method, which should dispose its members. Options: * The other hack would be to promote it from private to internal + use the InternalVisibleTo path to access it. Does anyone have something better ? Gishu
|