using System; using NUnit.Framework; namespace UnitTestBug { [TestFixture] public class Class { private class TestClass { ~TestClass() { throw new Exception("Throw exception in finalizer"); } } [Test] public void Test() { new TestClass(); for (int k = 16; k-- > 0;) { GC.Collect(GC.MaxGeneration); GC.WaitForPendingFinalizers(); } } } }