public void IsMathadorTest() { List <string> list = new List <string> { "2", "4", "6", "8", "10" }; //echec pour 1,2,3,4,5 string valueToFind = "20"; bool isMathador = MathadorSolver.IsMathador(list, valueToFind); Assert.AreEqual(true, isMathador); }
public void IsNotMathadorTest() { List <string> list = new List <string> { "12", "12", "12", "12", "12" }; string valueToFind = "15"; bool isMathador = MathadorSolver.IsMathador(list, valueToFind); Assert.AreEqual(false, isMathador); }
public void GenerateEntries() { /* * - 3 nombres entre 1 et 12 * - 2 nombres entre 1 et 20 * - le nombre cible entre 1 et 100 */ Random rnd = new Random(); JsonSerializer serializer = new JsonSerializer(); using (StreamWriter file = File.CreateText(@"" + path)) using (JsonTextWriter writer = new JsonTextWriter(file)) { writer.WriteStartArray(); for (float i = 0; i < nb && !requestStop; i++) { mathadorItem item; do { item = new mathadorItem((1 + rnd.Next(12)).ToString(), (1 + rnd.Next(12)).ToString(), (1 + rnd.Next(12)).ToString(), (1 + rnd.Next(20)).ToString(), (1 + rnd.Next(20)).ToString(), (1 + rnd.Next(100)).ToString()); } while (!MathadorSolver.IsMathador(item.valuesToList(), item.ValueToFind)); JObject obj = JObject.FromObject(item, serializer); obj.WriteTo(writer); writer.Flush(); if (i % 10 == 0) { Application.Current.Dispatcher.Invoke( new Action(() => { progress.Text = (i / nb * 100) + "%"; })); } } writer.WriteEndArray(); } if (!requestStop) { Application.Current.Dispatcher.Invoke(new Action(() => { button.IsEnabled = true; progress.Text = "100%"; button.Content = "Générer"; })); } }