Keyboard Shortcuts
Likes
Search
Re: [TDD] How do I unit test a Dispose method ?
Sorry - hit send too early: It depends.
If its Dispose() method has been called (its owner has requested early release of its resources), then it is required to call Dispose() on all of its?IDisposable?objects. However, if its Dispose() method is not called then cleanup is ultimately initiated by the GC through the Finalization Queue. As the order of finalization is not guaranteed, the object must not call Dispose() on any of its?IDisposable?objects.
This only applies to objects that it owns. Otherwise if it dispose of a reference that has been passed to it (say through injection) then it may be closing an object that is still required elsewhere.
On 3 February 2014 14:33, David Burstin <david.burstin@...> wrote:
|