protected override void Do() { if (Inputs.Count > 0) { Outputs = WFInvoker.Invoke(Inputs); } else { Outputs = WFInvoker.Invoke(); } }
/// <summary> /// A generic method for running any plugin test.<br /> /// It uses the test method itself to extract its name, /// replace 'Run' with 'Setup' to invoke the setup method for that test, /// and replace 'Run' with 'Verify' to invoke the verify method for that test. /// </summary> /// <param name="testMethod">The method object representing the test method.</param> protected void RunTest(MethodBase testMethod) { if (undoTestActions) { ((EnhancedOrgService)service).BeginTransaction(); } try { try { // invoke the setup method for this test var setupMethod = GetType().GetMethod("Setup" + testMethod.Name.Replace("Run", "") , BindingFlags.NonPublic | BindingFlags.Instance); if (setupMethod == null) { throw new Exception("Couldn't find setup method in test class."); } } catch (Exception ex) { testFailed = true; throw new Exception("Failed to run setup for test.", ex); } try { // run the activity logic Outputs = Inputs.Count > 0 ? WFInvoker.Invoke(Inputs) : WFInvoker.Invoke(); } catch (Exception ex) { Error = ex; testFailed = true; throw new Exception("Failed to run test.", ex); } try { // invoke the verify method for this test var verifyMethod = GetType().GetMethod("Verify" + testMethod.Name.Replace("Run", "") , BindingFlags.NonPublic | BindingFlags.Instance); if (verifyMethod == null) { throw new Exception("Couldn't find verification method in test class."); } verifyMethod.Invoke(this, null); } catch (Exception ex) { testFailed = true; throw new Exception("Failed to run verification for test.", ex); } } finally { if (undoTestActions) { try { ((EnhancedOrgService)service).EndTransaction(); } catch (Exception ex) { throw new Exception("Failed to undo test actions on CRM.", ex); } } } }