public void CanConfigureProcessorWithPipelineAndRegistry() { string preFilterNames = "FetchDataFilter;ValidParticipantFilter;"; string postFilterNames = "SaveDataFilter"; var parameters = new Dictionary<string, object>(); parameters.Add("FilterOrder", string.Empty); parameters.Add("FetchDataFired", false); parameters.Add("SaveDataFired", false); parameters.Add("ValidFired", false); var step = new Step("13", "12", "Manager Approve", "Request Promotion", "Approve", DateTime.Now, "Spock", "Spock;Kirk", parameters); step.CanProcess = true; var filterRegistry = new FilterRegistry<Step>(); var processor = new WorkflowProcessor(step, filterRegistry, new Workflow()); processor.ConfigurePipeline(preFilterNames, postFilterNames); var filterNames = processor.GetFilterNames(); filterNames.ForEach(x => Console.WriteLine(x)); Assert.AreEqual(4, filterNames.Count); }
public void CanConfigureProcessorStateMachine() { string source = @"F:\vs10dev\ApprovaFlowSimpleWorkflowProcessor\TestSuite\TestData\RequestPromotion.json"; var workflow = DeserializeWorkflow(source); var step = new Step("13", "12", "Manager Approve", "Request Promotion", "Approve", DateTime.Now, "Spock", "Spock;Kirk", new Dictionary<string, object>()); var filterRegistry = new FilterRegistry<Step>(); var processor = new WorkflowProcessor(step, filterRegistry, workflow); processor.ConfigureStateMachine(); Assert.AreEqual("Manager Approve", processor.GetCurrentState()); }
public void CanReportErrorsWithProcessor() { string source = @"F:\vs10dev\ApprovaFlowSimpleWorkflowProcessor\TestSuite\TestData\RequestPromotion.json"; string preFilterNames = "FetchDataFilter;ValidParticipantFilter;"; string postFilterNames = "SaveDataFilter"; var workflow = DeserializeWorkflow(source); var parameters = new Dictionary<string, object>(); parameters.Add("FilterOrder", string.Empty); parameters.Add("FetchDataFired", false); parameters.Add("SaveDataFired", false); parameters.Add("ValidFired", false); var step = new Step("13", "12", "ManagerReview", "RequestPromotionForm", "Approve", DateTime.Now, "Data", "Spock;Kirk", parameters); step.CanProcess = true; var filterRegistry = new FilterRegistry<Step>(); var processor = new WorkflowProcessor(step, filterRegistry, workflow); string newState = processor.ConfigurePipeline(preFilterNames, postFilterNames) .ConfigureStateMachine() .ProcessAnswer() .GetCurrentState(); Assert.AreEqual("ManagerReview", newState); Assert.AreEqual(1, processor.GetErrorList().Count); }
public void CanAllowMcCoyToIssueUnfitForDuty() { string source = @"F:\vs10dev\ApprovaFlowSimpleWorkflowProcessor\TestSuite\TestData\RedShirtPromotion.json"; string pluginSource = @"F:\vs10dev\ApprovaFlowSimpleWorkflowProcessor\TestSuite\TestPlugins"; string preFilterNames = "FetchDataFilter;MorePlugins.TransporterDiagnosisFilter;ValidParticipantFilter;"; string postFilterNames = "MorePlugins.TransporterRepairFilter;Plugins.CaptainUnfitForCommandFilter;SaveDataFilter;"; var workflow = DeserializeWorkflow(source); var parameters = new Dictionary<string, object>(); parameters.Add("FilterOrder", string.Empty); parameters.Add("FetchDataFired", false); parameters.Add("SaveDataFired", false); parameters.Add("ValidFired", false); // Mission to beam down issue and the red shirt wants off var step = new Step("13", "12", "RequestPromotionForm", "", "Complete", DateTime.Now, "RedShirtGuy", "Data;RedShirtGuy", parameters); step.CanProcess = true; var filterRegistry = new FilterRegistry<Step>(); filterRegistry.LoadPlugInsFromShare(pluginSource); var processor = new WorkflowProcessor(step, filterRegistry, workflow); string newState = processor.ConfigurePipeline(preFilterNames, postFilterNames) .ConfigureStateMachine() .ProcessAnswer() .GetCurrentState(); // Spock says he'll evaluate request Assert.AreEqual("FirstOfficerReview", newState); step.Answer = "Approve"; step.AnsweredBy = "Spock"; step.Participants = "Spock;Kirk"; step.State = newState; processor = new WorkflowProcessor(step, filterRegistry, workflow); newState = processor.ConfigurePipeline(preFilterNames, postFilterNames) .ConfigureStateMachine() .ProcessAnswer() .GetCurrentState(); Assert.AreEqual("CaptainApproval", newState); // Captain Kirt denies request, but McCoy issues unfit for command parameters.Add("KirkInfected", true); step.Answer = "Deny"; step.AnsweredBy = "Kirk"; step.Participants = "Kirk"; step.State = newState; processor = new WorkflowProcessor(step, filterRegistry, workflow); newState = processor.ConfigurePipeline(preFilterNames, postFilterNames) .ConfigureStateMachine() .ProcessAnswer() .GetCurrentState(); // Medical override issued and email to Starfleet generated bool medicalOverride = (bool)parameters["MedicalOverride"]; bool emailSent = (bool)parameters["StarfleetEmail"]; Assert.IsTrue(medicalOverride); Assert.IsTrue(emailSent); }
public void CanPromoteRedShirtOffLandingParty() { string source = @"F:\vs10dev\ApprovaFlowSimpleWorkflowProcessor\TestSuite\TestData\RedShirtPromotion.json"; string preFilterNames = "FetchDataFilter;ValidParticipantFilter;"; string postFilterNames = "SaveDataFilter"; var workflow = DeserializeWorkflow(source); var parameters = new Dictionary<string, object>(); parameters.Add("FilterOrder", string.Empty); parameters.Add("FetchDataFired", false); parameters.Add("SaveDataFired", false); parameters.Add("ValidFired", false); var step = new Step("13", "12", "RequestPromotionForm", "", "Complete", DateTime.Now, "RedShirtGuy", "Data;RedShirtGuy", parameters); step.CanProcess = true; var filterRegistry = new FilterRegistry<Step>(); var processor = new WorkflowProcessor(step, filterRegistry, workflow); string newState = processor.ConfigurePipeline(preFilterNames, postFilterNames) .ConfigureStateMachine() .ProcessAnswer() .GetCurrentState(); Assert.AreEqual("FirstOfficerReview", newState); step.Answer = "Approve"; step.AnsweredBy = "Spock"; step.Participants = "Spock;Kirk"; step.State = newState; processor = new WorkflowProcessor(step, filterRegistry, workflow); newState = processor.ConfigurePipeline(preFilterNames, postFilterNames) .ConfigureStateMachine() .ProcessAnswer() .GetCurrentState(); Assert.AreEqual("CaptainApproval", newState); step.Answer = "Approve"; step.AnsweredBy = "Kirk"; step.Participants = "Kirk"; step.State = newState; processor = new WorkflowProcessor(step, filterRegistry, workflow); newState = processor.ConfigurePipeline(preFilterNames, postFilterNames) .ConfigureStateMachine() .ProcessAnswer() .GetCurrentState(); Assert.AreEqual("PromotedOffLandingParty", newState); }
public void CanPreventMcCoyFromOverridingKirk() { string source = @"F:\vs10dev\ApprovaFlowSimpleWorkflowProcessor\TestSuite\TestData\RedShirtPromotion.json"; string preFilterNames = "FetchDataFilter;ValidParticipantFilter;"; string postFilterNames = "SaveDataFilter"; var workflow = DeserializeWorkflow(source); var parameters = new Dictionary<string, object>(); parameters.Add("FilterOrder", string.Empty); parameters.Add("FetchDataFired", false); parameters.Add("SaveDataFired", false); parameters.Add("ValidFired", false); var step = new Step("13", "12", "RequestPromotionForm", "", "Complete", DateTime.Now, "RedShirtGuy", "Data;RedShirtGuy", parameters); step.CanProcess = true; var filterRegistry = new FilterRegistry<Step>(); var processor = new WorkflowProcessor(step, filterRegistry, workflow); string newState = processor.ConfigurePipeline(preFilterNames, postFilterNames) .ConfigureStateMachine() .ProcessAnswer() .GetCurrentState(); Assert.AreEqual("FirstOfficerReview", newState); step.Answer = "Approve"; step.AnsweredBy = "Spock"; step.Participants = "Spock;Kirk"; step.State = newState; processor = new WorkflowProcessor(step, filterRegistry, workflow); newState = processor.ConfigurePipeline(preFilterNames, postFilterNames) .ConfigureStateMachine() .ProcessAnswer() .GetCurrentState(); Assert.AreEqual("CaptainApproval", newState); // Workflow will not process the trigger because // the ValidParticipant filter will set setp.CanProcess to false step.Answer = "Approve"; step.AnsweredBy = "McCoy"; step.Participants = "Kirk"; step.State = newState; processor = new WorkflowProcessor(step, filterRegistry, workflow); newState = processor.ConfigurePipeline(preFilterNames, postFilterNames) .ConfigureStateMachine() .ProcessAnswer() .GetCurrentState(); Assert.AreEqual("CaptainApproval", newState); Assert.IsFalse(step.CanProcess); Assert.AreEqual(1, processor.GetErrorList().Count); Console.WriteLine(processor.GetErrorList()[0]); }
public void CanIssueSpecialOrdersWithPlugin() { string source = @"F:\vs10dev\ApprovaFlowSimpleWorkflowProcessor\TestSuite\TestData\RedShirtPromotion.json"; string pluginSource = @"F:\vs10dev\ApprovaFlowSimpleWorkflowProcessor\TestSuite\TestPlugins"; string preFilterNames = "FetchDataFilter;MorePlugins.TransporterDiagnosisFilter;ValidParticipantFilter;"; string postFilterNames = "MorePlugins.TransporterRepairFilter;SaveDataFilter;"; var workflow = DeserializeWorkflow(source); var parameters = new Dictionary<string, object>(); parameters.Add("FilterOrder", string.Empty); parameters.Add("FetchDataFired", false); parameters.Add("SaveDataFired", false); parameters.Add("ValidFired", false); var step = new Step("13", "12", "RequestPromotionForm", "", "Complete", DateTime.Now, "RedShirtGuy", "Data;RedShirtGuy", parameters); step.CanProcess = true; var filterRegistry = new FilterRegistry<Step>(); filterRegistry.LoadPlugInsFromShare(pluginSource); var processor = new WorkflowProcessor(step, filterRegistry, workflow); string newState = processor.ConfigurePipeline(preFilterNames, postFilterNames) .ConfigureStateMachine() .ProcessAnswer() .GetCurrentState(); Assert.AreEqual("FirstOfficerReview", newState); step.Answer = "Approve"; step.AnsweredBy = "Spock"; step.Participants = "Spock;Kirk"; step.State = newState; processor = new WorkflowProcessor(step, filterRegistry, workflow); newState = processor.ConfigurePipeline(preFilterNames, postFilterNames) .ConfigureStateMachine() .ProcessAnswer() .GetCurrentState(); Assert.AreEqual("CaptainApproval", newState); // Captain Kirt denies request, special order issued step.Answer = "Deny"; step.AnsweredBy = "Kirk"; step.Participants = "Kirk"; step.State = newState; processor = new WorkflowProcessor(step, filterRegistry, workflow); newState = processor.ConfigurePipeline(preFilterNames, postFilterNames) .ConfigureStateMachine() .ProcessAnswer() .GetCurrentState(); Assert.AreEqual("Report to Shuttle Bay", step.Parameters["SpecialOrders"].ToString()); }