public void TestCalcul2x2() { Calcul calcul = new Calcul(); Size sz = new Size(2, 2); List <IList <int> > positionsGagnantes = new List <IList <int> >(); positionsGagnantes.Add(new int[] { 2, 3 }); int handler = calcul.ComputeDock(sz, 2, positionsGagnantes); // Cette position est celle qui demande le plus grand nombre de mouvements pour sa résolution : 6 IList <int> position = new int[] { 1, 0 }; IList <int> solution = calcul.GetSolution(handler, position); IList <int> solutionAttendue = new int[] { 1, 3, 2, 0, 1, 3 }; Assert.AreEqual(solution.Count, solutionAttendue.Count); for (int i = 0; i < solution.Count; i++) { Assert.AreEqual(solution[i], solutionAttendue[i]); } }
public void TestDump2x3() { Calcul calcul = new Calcul(); Size sz = new Size(2, 3); List <IList <int> > positionsGagnantes = new List <IList <int> >(); positionsGagnantes.Add(new int[] { 0, 1, 2 }); positionsGagnantes.Add(new int[] { 0, 1, 3 }); int handler = calcul.ComputeDock(sz, 3, positionsGagnantes); List <List <string> > dump = calcul.DumpDock(handler); FileInfo fi = new FileInfo("Dump2x3.xlsx"); using (ExcelPackage excel = new ExcelPackage()) { ExcelWorksheet ws = excel.Workbook.Worksheets.Add("dump"); int row, col; row = 1; foreach (List <string> itemRow in dump) { col = 1; foreach (string item in itemRow) { int x, y; for (int i = 0; i < item.Length; i++) { x = i % 2; y = i / 2; ExcelRange cell = ws.Cells[row + y, col + x]; cell.Value = "" + item[i]; cell.Style.Border.BorderAround(OfficeOpenXml.Style.ExcelBorderStyle.Thin); } col += 3; } row += 4; } excel.SaveAs(fi); } System.Diagnostics.Process.Start(fi.FullName); }