public void DisposeWhenNullTargetPasses() { var target = new LayoutClass(); target.Dispose(); Assert.IsNull(target.Target); }
public void OnDisposedWhenThrowExceptionPasses() { var target = new LayoutClass(); target.Target = new LayoutTargetObject(); target.OnDisposed.Add((_self) => { throw new System.Exception(); }); Assert.DoesNotThrow(() => target.Dispose()); Assert.IsNull(target.Target); Assert.AreEqual(0, target.OnDisposed.RegistedDelegateCount); }
public void DisposePasses() { var target = new LayoutClass(); var obj = new LayoutTargetObject(); Assert.AreEqual(0, obj.OnDisposed.RegistedDelegateCount); target.Target = obj; Assert.AreEqual(1, obj.OnDisposed.RegistedDelegateCount); target.Dispose(); Assert.IsNull(target.Target); Assert.AreEqual(0, obj.OnDisposed.RegistedDelegateCount, $"Remove a callback of LayoutBase from ILayoutTarget#OnDisposed After LayoutBase#Dispose()"); }
public void OnDisposedPasses() { var target = new LayoutClass(); var callCounter = 0; ILayout recievedValue = null; target.OnDisposed.Add((_self) => { callCounter++; recievedValue = _self; }); target.Dispose(); Assert.AreEqual(1, callCounter); Assert.AreSame(target, recievedValue); Assert.AreEqual(0, target.OnDisposed.RegistedDelegateCount); }