public void ContextCopyingRunnableEqualsRunnableFromSameSource() { var r = new Runnable(_runnable.Run); Assert.That(_sut, Is.EqualTo(r)); Assert.IsTrue(r.Equals(_sut)); Assert.IsTrue(_sut.Equals(r)); Assert.IsTrue(r.Equals(new ContextCopyingRunnable(r, null))); Assert.IsTrue(new ContextCopyingRunnable(r, null).Equals(r)); }
public void EqualsWhenAndOnlyWhenActionEquals() { _runnable = new Runnable(_action); object run = new Runnable(Run); Assert.IsTrue(run.Equals(run)); Assert.IsFalse(run.Equals(null)); Assert.IsTrue(_runnable.Equals(_runnable)); Assert.IsTrue(_runnable.Equals(new Runnable(_action))); Assert.IsTrue(run.Equals(new Runnable(Run))); Assert.IsFalse(_runnable.Equals(new object())); Assert.IsFalse(_runnable.Equals(null)); Assert.IsFalse(_runnable.Equals(run)); }
/// <summary> /// Stop this container. /// </summary> /// <param name="callback"> /// The callback. /// </param> public void Stop(Runnable callback) { this.Stop(); callback.Run(); }
public void ExplicitConvertTaskDelegateToRunnable() { _runnable = (Runnable)_action; Assert.That(_runnable, Is.Not.Null); Assert.That(!_isDelegateCalled); _runnable.Run(); Assert.That(_isDelegateCalled); }
public void ExplicitConvertRunnableToTaskDelegate() { _runnable = new Runnable(_action); Action action = (Action)_runnable; Assert.That(action, Is.SameAs(_action)); }
public void ExplicitConvertNullTaskDelegateToNullRunnable() { _action = null; _runnable = (Runnable)_action; Assert.That(_runnable, Is.Null); }
public void ExplicitConvertNullRunnableToNullTaskDelegate() { _runnable = null; Action action = (Action)_runnable; Assert.That(action, Is.Null); }
public void TaskReturnsTheResultOfDelegate() { _runnable = new Runnable(_action); Assert.That(!_isDelegateCalled); _runnable.Run(); Assert.That(_isDelegateCalled); }
public void GetHashCodeReturnsHashCodeOfInnerAction() { _runnable = new Runnable(_action); var run = new Runnable(Run); Assert.That(_runnable.GetHashCode(), Is.EqualTo(_action.GetHashCode())); Assert.That(run.GetHashCode(), Is.EqualTo(new Action(Run).GetHashCode())); }
/// <summary> /// Determines whether the specified <paramref name="other"/> instance /// is equal to the current <see cref="Runnable"/>. /// </summary> /// <returns> /// true if the <paramref name="other"/> carrys the same inner action /// as current instance; otherwise, false. /// </returns> /// <param name="other"> /// The other <see cref="Runnable"/> to compare with the current instance. /// </param> public virtual bool Equals(Runnable other) { if (ReferenceEquals(null, other)) return false; if (ReferenceEquals(this, other)) return true; return Equals(other._action, _action); }