private void ExecuteAction(UserAction action) { var actionType = action.GetType(); var executor = _executors[actionType]; var executeMethod = typeof(IUserActionExecutor <>).MakeGenericType(actionType).GetMethod("Execute"); executeMethod.Invoke(executor, new object[] { action }); }
public void testClickButton(int abili, int userID, int cardID, Type expected) { try { UserActionHandler handler = new UserActionHandler(game); handler.ClickUser = userID; handler.SelectCardId = cardID; handler.Ifabi = abili; UserAction action = handler.clickOK(1); if (expected == null) { Assert.Fail("Should throw an exception"); } Assert.AreEqual(expected, action.GetType()); } catch (InvalidOperationException e) { if (expected != null) { Assert.Fail("Should not throw an exception"); } } }
private string GetContentPartialViewName(UserAction forAction) { return(string.Format("_{0}", Enum.GetName(forAction.GetType(), forAction))); }