¿ªÔÆÌåÓý

ctrl + shift + ? for shortcuts
© 2025 Groups.io
Testing a class which utilizes randomness
Hello! I'm new to TDD and this group. For practice, I started a simple project and now I want to create a list of random strings, but such that no two strings are ever the same. In a very unlikely,
By Nikola Novak <reasonsharp@...> · #35500 ·
Re: How do I unit test a Dispose method ?
Whoops just saw yesterday's message came in all garbled.. here it is again properly formatted.. ========================== Hi again Gishu and all, Seems like this thread has grown since
By avi_a@... · #35499 ·
Re: How do I unit test a Dispose method ?
Hi again Gishu and all, Seems like this thread has grown since I last looked :) What I used to do in this case is inject the disposable object as a collaborator (interface representing its role) into
By avi_a@... · #35498 ·
Re: How do I unit test a Dispose method ?
Nope. I did test-drive this design. The connection instance represents an open connection to a hardware device. All conn parameters appear as constructor parameters of this type - one of which is a
By Gishu · #35497 ·
Re: [TDD] RE: How do I unit test a Dispose method ?
Yes, +1 to that. I¡¯ve been wondering what the business or functional need was that was driving that particular implementation and whether it might have been done differently. And for sure it would
By Donaldson, John <john.m.donaldson@...> · #35496 ·
Re: How do I unit test a Dispose method ?
Hi Gishu Sorry if my reply is out of context - I've been having trouble finding all the replies in the new (?) Yahoo group UI.... In general - the idea is the tests drive your design. Here it
By avi_a@... · #35495 ·
Re: [TDD] How do I unit test a Dispose method ?
AHA! But then a factory should not be using the objects it creates.... :) Sent: Monday, February 03, 2014 8:40 AM To: testdrivendevelopment@... Subject: RE: [TDD] How do I unit test a
By Amir Kolsky · #35494 ·
Re: [TDD] How do I unit test a Dispose method ?
Unless it's a factory
By Avi Kessner · #35493 ·
Re: [TDD] How do I unit test a Dispose method ?
I agree, my point is that you should ALWAYS be given the object rather than it belonging to you. Therefore, the whole IDisposable pattern seems flawed from a design perspective. All that said, you
By Amir Kolsky · #35492 ·
Re: [TDD] How do I unit test a Dispose method ?
...except, if you're given the object rather than creating it yourself, then its lifetime doesn't belong to you, and you don't need to be concerned with whether it's
By Brad Wilson <dotnetguy@...> · #35491 ·
Re: [TDD] How do I unit test a Dispose method ?
If A cares about this specific property it would require B to implement IDisposable. From A's perspective, it is given an object of type B to perform a specific action. B would be available to A
By Amir Kolsky · #35490 ·
Re: [TDD] How do I unit test a Dispose method ?
Amir, I feel like I might be missing your point. Why is it unreasonable for A to know that B uses expensive resources and provides a way to release them early? Surely this was one of
By David Burstin · #35489 ·
Re: [TDD] How do I unit test a Dispose method ?
Except that B must already be IDisposable. The IDisposable pattern requires that any object that owns an IDisposable must itself implement IDisposable. * This is inane, as it requires the owning
By Amir Kolsky · #35488 ·
Re: [TDD] How do I unit test a Dispose method ?
I disagree. All that A needs to know is that B implements the IDisposable interface. The only reason to ever call Dispose() is to initiate an early release of expensive internal resources. If the
By David Burstin · #35487 ·
Re: [TDD] How do I unit test a Dispose method ?
I agree that it is difficult. Here is the test list that I used: - when the Finalizer is called it releases all unmanaged resources - when the Finalizer is called it does NOT Dispose its
By David Burstin · #35486 ·
Re: [TDD] How do I unit test a Dispose method ?
Except that B must already be IDisposable. The IDisposable pattern requires that any object that owns an IDisposable must itself implement IDisposable. n This is inane, as it requires the owning
By Amir Kolsky · #35485 ·
Re: [TDD] How do I unit test a Dispose method ?
Except that B must already be IDisposable. The IDisposable pattern requires that any object that owns an IDisposable must itself implement IDisposable. I agree completely. My original point was
By David Burstin · #35484 ·
Re: [TDD] How do I unit test a Dispose method ?
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
By Amir Kolsky · #35483 ·
Re: [TDD] How do I unit test a Dispose method ?
That is what I thought. So I object A uses B and C and C (and A) are IDisposable, we need to ascertain that C's Dispose is called, right? Note, however, that the fact that A uses B and C, is an
By Amir Kolsky · #35482 ·
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
By David Burstin · #35481 ·