public void CallbackMatcherTest2(Mock <IParentInterface> mock) { var callback = new CallbackMatcher <Action <IEnumerable <Version> > >(); mock.Expects.One.Method(_ => _.AsyncMethod((Action <IEnumerable <Version> >)null)).With(callback); var presenter = new TestPresenter(mock.MockObject); presenter.BeginIEnumerableInvoke(); Assert.IsTrue(string.IsNullOrEmpty(presenter.Status)); var versions = new List <Version> { new Version(1, 1, 1, 1), new Version(2, 2, 2, 2), new Version(3, 3, 3, 3) }; callback.Callback(versions); Assert.AreEqual(string.Format(TestPresenter.END_INVOKE_COUNT, 3), presenter.Status); }
public void CallbackListMatcherTest1() { var callback = new CallbackListMatcher <Action <IEnumerable <Version> > >(); _mock.Expects.Exactly(2).Method(_ => _.AsyncMethod((Action <IEnumerable <Version> >)null)).With(callback); TestPresenter presenter1 = new TestPresenter(_mock.MockObject); TestPresenter presenter2 = new TestPresenter(_mock.MockObject); presenter1.BeginIEnumerableInvoke(); presenter2.BeginIEnumerableInvoke(); Assert.IsTrue(string.IsNullOrEmpty(presenter1.Status)); Assert.IsTrue(string.IsNullOrEmpty(presenter2.Status)); var versions = new List <Version> { new Version(1, 1, 1, 1), new Version(2, 2, 2, 2), new Version(3, 3, 3, 3) }; callback.Callbacks.ForEach(_ => _.Invoke(versions)); Assert.AreEqual(string.Format(TestPresenter.END_INVOKE_COUNT, 3), presenter1.Status); Assert.AreEqual(string.Format(TestPresenter.END_INVOKE_COUNT, 3), presenter2.Status); }