public void Test1(string[] values, int neg, double sum, double mult, double div) { var dictionary = new Dictionary <string, double>(); for (int i = 0; i < values.Length - 1; i += 2) { double number = 0; double.TryParse(values[i], out number); dictionary.Add(values[i + 1], number); } var count = dictionary.Count; var outcome = prog.RetrieveCalValues(dictionary); Assert.True(outcome.ContainsKey("sum"), "Missing key for the sum of the entries"); Assert.True(outcome.ContainsKey("mult"), "Missing key for the product of the entries"); Assert.True(outcome.ContainsKey("div"), "Missing key for the division result of the entries"); Assert.True(outcome.Count == count + 3 - neg, "The negative elements were not removed"); try { var vsum = Math.Round(outcome["sum"], 10); var vmult = Math.Round(outcome["mult"], 10); var vdiv = Math.Round(outcome["div"], 10); Assert.True(vsum == Math.Round(sum, 10), $"You should have returned sum: {sum}, but did return sum: {vsum}."); Assert.True(vmult == Math.Round(mult, 10), $"You should have returned mult: {mult} but did return mult: {vmult}."); Assert.True(vdiv == Math.Round(div, 10), $"You should have returned div: {div} but did return div: {vdiv}."); } catch (KeyNotFoundException ex) { Console.Error.WriteLine(ex.Message); } }
public void Test(string[] values, int result) { var dictionary = new Dictionary <string, double>(); for (int i = 0; i < values.Length - 1; i += 2) { double number = 0; double.TryParse(values[i], out number); dictionary.Add(values[i + 1], number); } var outcome = prog.RetrieveCalValues(dictionary); Assert.True(outcome == result, $"You should have returned {result} but did return {outcome}."); }