C# out of scope objects not getting collected
问题 I'm trying to build my first unit tests and have a class that increments and decrements an instance counter in it's constructor and destructor respectively. I have a test to make sure this works but it fails, it seems that other instances of the class from my other tests aren't having their destructor called when they go out of scope. public class Customer { public Customer() { ++InstanceCount; } public Customer(int customerId) { CustomerId = customerId; ++InstanceCount; } ~Customer() { -