public void VectorChanged_NonActionAdded_ExceptionThrown() { ActionCollection actionCollection = new ActionCollection(); actionCollection.Add(new StubAction()); TestUtilities.AssertThrowsException(() => actionCollection.Add(new Button())); }
public void ExecuteActions_ActionsWithResults_ResultsInActionOrder() { string[] expectedReturnValues = { "A", "B", "C" }; ActionCollection actions = new ActionCollection(); foreach (string returnValue in expectedReturnValues) { actions.Add(new StubAction(returnValue)); } List<object> results = Interaction.ExecuteActions(null, actions, null).ToList(); Assert.AreEqual(expectedReturnValues.Length, results.Count, "Should have the same number of results as IActions."); for (int resultIndex = 0; resultIndex < results.Count; resultIndex++) { Assert.AreEqual(expectedReturnValues[resultIndex], results[resultIndex], "Results should be returned in the order of the actions in the ActionCollection."); } }
public void ExecuteActions_MultipleActions_AllActionsExecuted() { ActionCollection actions = new ActionCollection(); actions.Add(new StubAction()); actions.Add(new StubAction()); actions.Add(new StubAction()); Button sender = new Button(); string parameterString = "TestString"; Interaction.ExecuteActions(sender, actions, parameterString); foreach (StubAction action in actions) { Assert.AreEqual(1, action.ExecuteCount, "Each IAction should be executed once."); Assert.AreEqual(sender, action.Sender, "Sender is passed to the actions."); Assert.AreEqual(parameterString, action.Parameter, "Parameter is passed to the actions."); } }