/// <summary> /// Get the tree /// </summary> /// <returns> /// The <see> /// <cref>ITree</cref> /// </see> /// . /// </returns> private static ITree <GoalSeekContext> GetTree() { var root = new Trunk(ScriptHelper.GetScript <GoalSeekContext>("Tax = (decimal)(TargetDecimal * (decimal)0.3)")); root.AddSection(ScriptHelper.GetScript <GoalSeekContext>("Tax = (decimal)(Tax + 1000)")) .AddSection(ScriptHelper.GetScript <GoalSeekContext>("TargetDecimal = TargetDecimal - Tax + DecimalToManipulate")); return(new Tree <GoalSeekContext>(root, new Producer <GoalSeekContext>())); }
public async Task MultipleSequentialSegmentsTest() { // Given var root = new Trunk(CreateScript("Z = X + Y")); root.AddSection(CreateScript("Z = Z * 10")).AddSection(CreateScript("Y = Y * Y")).AddSection(CreateScript("X = -123")); ITree <TreeTestContext> tree = new Tree <TreeTestContext>(root, Producer); var context = new TreeTestContext(1, 3); // When await tree.Run(context); // Then Assert.AreEqual(-123, context.X); Assert.AreEqual(9, context.Y); Assert.AreEqual(40, context.Z); }