public void Dev2ActionCollection_Enumerate() { var collection = new Dev2ActionCollection(_taskServiceConvertorFactory.Object, _nativeInstance); var nativeAction = new ExecAction("a", "b", "c"); var actionToAdd = new Dev2ExecAction(_taskServiceConvertorFactory.Object, nativeAction); _taskServiceConvertorFactory.Setup(a => a.CreateAction(nativeAction)).Returns(actionToAdd); collection.Add(actionToAdd); var nativeAction1 = new ExecAction("1", "2", "3"); var nativeAction2 = new ExecAction("4", "6", "4"); var actionToAdd1 = new Dev2ExecAction(_taskServiceConvertorFactory.Object, nativeAction1); var actionToAdd2 = new Dev2ExecAction(_taskServiceConvertorFactory.Object, nativeAction2); _taskServiceConvertorFactory.Setup(a => a.CreateAction(It.IsAny<ExecAction>())).Returns(actionToAdd); collection.Add( actionToAdd1); collection.Add( actionToAdd2); var e =collection.GetEnumerator(); Assert.IsTrue(e.MoveNext()); Assert.AreEqual(((ExecAction)e.Current.Instance).Path,"a"); _taskServiceConvertorFactory.Setup(a => a.CreateAction(It.IsAny<ExecAction>())).Returns(actionToAdd1); Assert.IsTrue(e.MoveNext()); Assert.AreEqual(((ExecAction)e.Current.Instance).Path, "1"); _taskServiceConvertorFactory.Setup(a => a.CreateAction(It.IsAny<ExecAction>())).Returns(actionToAdd2); Assert.IsTrue(e.MoveNext()); Assert.AreEqual(((ExecAction)e.Current.Instance).Path, "4"); Assert.IsFalse(e.MoveNext()); }
private Dev2ActionCollection CreateCollection() { var collection = new Dev2ActionCollection(_taskServiceConvertorFactory.Object, _nativeInstance); var nativeAction = new ExecAction("a", "b", "c"); var actionToAdd = new Dev2ExecAction(_taskServiceConvertorFactory.Object, nativeAction); _taskServiceConvertorFactory.Setup(a => a.CreateAction(nativeAction)).Returns(actionToAdd); collection.Add(actionToAdd); return collection; }