public void Test() { var tc = new TestClass(); Assert.IsTrue(string.IsNullOrEmpty(tc.InstanceName)); tc.ErrorEvent += Tc_ErrorEvent; ErrorEvent = null; var ex = new Exception("test"); Assert.IsNull(ErrorEvent); tc.SendErrorEvent(ex); Assert.IsNotNull(ErrorEvent); // ReSharper disable once PossibleNullReferenceException Assert.AreSame(ex, ErrorEvent.GetException()); tc.PropertyChanged += Tc_PropertyChanged; PropertyChangedEvent = null; var propName = nameof(ErrorEvent); Assert.IsNull(PropertyChangedEvent); tc.SendPropertyChanged(propName); Assert.IsNotNull(PropertyChangedEvent); // ReSharper disable once PossibleNullReferenceException Assert.AreEqual(propName, PropertyChangedEvent.PropertyName); tc.DisposeCalled = false; Assert.IsFalse(tc.IsDisposed); Assert.IsFalse(tc.DisposeCalled); tc.Dispose(); Assert.IsTrue(tc.IsDisposed); Assert.IsTrue(tc.DisposeCalled); tc.DisposeCalled = false; Assert.IsFalse(tc.DisposeCalled); tc.Dispose(); Assert.IsFalse(tc.DisposeCalled); var className = "ClassName"; tc = new TestClass(className); Assert.AreEqual(className, tc.InstanceName); }