public void DisposeTest() { var obj = new ModelClass() { Property = 12, PropertyLink = "asd" }; void Test(bool resource, bool disposed, string prefix) { Assert.AreEqual(obj.Resource, resource, $"({prefix}) Resource:{obj.Resource}"); Assert.AreEqual(obj.IsDisposed, disposed, $"({prefix}) Disposed:{obj.IsDisposed}"); } Test(true, false, "1"); obj.Disposing += (q, w) => Test(true, false, "2/1"); obj.NewDisposing += (q, w) => Test(true, false, "2/1"); obj.Disposed += (q, w) => Test(false, true, "3/1"); obj.NewDisposed += (q, w) => Test(false, true, "3/2"); obj.Dispose(); Test(false, true, "4"); }
public void EventNullTest() { var obj = new ModelClass() { Property = 12, PropertyLink = "asd" }; try { obj.Property = 14; obj.Initialize(); obj.FinalizeObject(); obj.Dispose(); } catch (NullReferenceException) { throw new Exception("TestFailed.. NullReferenceException"); } }