private static Flow DefineDemoCurrencyConverterSteps() { var retVal = new Flow(); retVal.Add(new Step("10", "Enter 1st currency", "Plugin.ConsoleUI.PublishStringFromUI")); retVal.Add(new Step("20", "Enter 2nd currency", "Plugin.ConsoleUI.PublishStringFromUI")); var trickyStep = new Step("30", "Get exchange rate", "Plugin.Demo.CurrencyConverter.GetExchangeRate"); trickyStep.AddParameter("String", 1, new Parameter("String", "10", 0)); trickyStep.AddParameter("String", 2, new Parameter("String", "20", 0)); retVal.Add(trickyStep); retVal.Add(new Step("40", "Format result", "Plugin.Demo.Calculator.FormatNumber", new[] { new Parameter("Number", "30", 0), })); retVal.Add(new Step("50", "Display result", "Plugin.ConsoleUI.DisplayString", new[] { new Parameter("String", "40", 0), })); return retVal; }
private static Flow DefineDemoCalculatorSteps() { var retVal = new Flow(); retVal.Add(new Step("10", "Enter 1st integer", "Plugin.ConsoleUI.PublishIntegerFromUI")); retVal.Add(new Step("20", "Enter 2nd integer", "Plugin.ConsoleUI.PublishIntegerFromUI")); var trickyStep = new Step("30", "Compute stuff", "Plugin.Demo.Calculator.DoArithmetic"); trickyStep.AddParameter("Integer", 100, new Parameter("Integer", "10", 0)); trickyStep.AddParameter("Integer", 200, new Parameter("Integer", "20", 0)); retVal.Add(trickyStep); retVal.Add(new Step("40", "Format result", "Plugin.Demo.Calculator.FormatNumber", new[] { new Parameter("Number", "30", 3), })); retVal.Add(new Step("50", "Display result", "Plugin.ConsoleUI.DisplayString", new[] { new Parameter("String", "40", 0), })); return retVal; }
public void ValidateAddsErrorIfNumberOfInputParametersIsMoreThanExpected() { // Arrange var x = new Flow(); var step = new Step(null, "PrintInt"); var prm1 = new Parameter("int", step.Id, 0); var prm2 = new Parameter("string", step.Id, 0); step.AddParameter(prm1); step.AddParameter(prm2); x.Add(step); var actions = new CalculatorActionDefinitionProvider().Get; // Act var errors = x.Validate(actions); // Assert Assert.IsNotNull(errors); Assert.AreEqual(1, errors.Count); Assert.IsTrue(errors[0].Message.Contains("Number of input parameters")); }
public void ValidateAddsErrorIfParameterWasNotPreviouslyPublished() { // Arrange var x = new Flow(); var step = new Step(null, "PrintInt"); var prm = new Parameter("int", step.Id, 0); step.AddParameter(prm); x.Add(step); var actions = new CalculatorActionDefinitionProvider().Get; // Act var errors = x.Validate(actions); // Assert Assert.IsNotNull(errors); Assert.AreEqual(1, errors.Count); Assert.IsTrue(errors[0].Message.Contains("has not been previously published")); }
private static Flow CreateValidFlow() { var x = new Flow(); var step1 = new Step("1", "Get 1st int", "GetIntFromUI"); var step2 = new Step("2", "Get 2nd int", "GetIntFromUI"); var step3 = new Step("3", "Do the math", "DoArithmetic"); step3.AddParameter("int", 111, new Parameter("int", step1.Id, 0)); step3.AddParameter("int", 222, new Parameter("int", step2.Id, 0)); var step4 = new Step("4", "Print product", "PrintInt", new[] { new Parameter("int", step3.Id, 333) }); x.Add(step1); x.Add(step2); x.Add(step3); x.Add(step4); return x; }