public CharacterSheet() { Formulas = new AlgexSet(){ImmediateSolve = true}; Boxes = new List<IFormulable>(); PreviewMode = true; Blocks = new List<IPlaceable>(); }
public void ExpressionSetTest() { var tests = new Tuple<string, string, double>[] { new Tuple<string, string, double>("a", "2", 2), new Tuple<string, string, double>("b", "{a}-1", 1), new Tuple<string, string, double>("c","{a}+{b}", 3), new Tuple<string, string, double>("d","{a}*{c}", 6), new Tuple<string, string, double>("e","{d}-{b}", 5), new Tuple<string, string, double>("f","{e}+4*{b}", 9), new Tuple<string, string, double>("g","{f}/{c}+1", 4), new Tuple<string, string, double>("all","({f}/{c}-{g}+{b})*({a}+{f})+{d}*{e}", 30) }; var set = new AlgexSet(); foreach (var test in tests) { set.Add(test.Item1, test.Item2); } set.SolveAll(); foreach (var test in tests) { Assert.AreEqual(test.Item3, set[test.Item1]); } }
public void ExpressionSetTestRenameVariable() { var tests = new List<Tuple<string, string, double>> { new Tuple<string, string, double>("a", "2", 2), new Tuple<string, string, double>("b", "{a}-1", 1), new Tuple<string, string, double>("c","{a}+{b}", 3), new Tuple<string, string, double>("d","{a}*{c}", 6), new Tuple<string, string, double>("e","{d}-{b}", 5), new Tuple<string, string, double>("f","{e}+4*{b}", 9), new Tuple<string, string, double>("g","{f}/{c}+1", 4), new Tuple<string, string, double>("all","({f}/{c}-{g}+{b})*({a}+{f})+{d}*{e}", 30) }; var set = new AlgexSet(); set.ImmediateSolve = true; foreach (var test in tests) { set.Add(test.Item1, test.Item2); } set.RenameVariable("c", "cc"); tests[2] = new Tuple<string, string, double>("cc", "{a}+{b}", 3); foreach (var test in tests) { Assert.AreEqual(test.Item3, set[test.Item1]); } }