public void RunAlgorithmTest() { // Initialise Space ISpace <int> space = new Space <int>(new Possible() { 1, 2, 3, 4, 5, 6, 7, 8, 9 }); for (int i = 1; i < 82; i++) { space.Add(i, new Possible() { 1, 2, 3, 4, 5, 6, 7, 8, 9 }); } // Initialise one group (top row) Keys <int> group = new Keys <int>() { 1, 2, 3, 4, 5, 6, 7, 8, 9 }; IPuzzle <int> puzzle = new PuzzleBase <int>(space); IPuzzleEngine <int> engine = new PuzzleEngine <int>(puzzle); // Action space[1].SetValue(1); Keys <int> keysInner = new Keys <int>() { 1 }; int jobsAdded = ConstraintMutuallyExclusive <int> .CreateCompleteSetActions(keysInner, group, engine); // Test Keys <int> expectedK = new Keys <int>() { 2, 3, 4, 5, 6, 7, 8, 9 }; Possible expectedV = new Possible() { 1 }; IJobFilter <int> job = engine.Peek() as IJobFilter <int>; Keys <int> actual = job.Keys; IPossible filter = job.Filter; // Check the algorithm returned 8 changes Assert.AreEqual(8, actual.Count(), "Algorithm Eliminate did not return 8 changes"); Assert.IsTrue(expectedK.SetEquals(actual)); Assert.AreEqual(1, filter.Count, "Filter value incorrect"); Assert.IsTrue(expectedV.SetEquals(filter), "Filter values incorrect"); }
public void RunAlgorithmEliminateTest1() { // Initialise Possible IPossible possibleAll = new Possible() { 1, 2, 3, 4, 5, 6, 7, 8, 9 }; // Initialise Space ISpace <int> space = new Space <int>(new Possible() { 1, 2, 3, 4, 5, 6, 7, 8, 9 }); for (int i = 1; i < 82; i++) { space.Add(i, new Possible(possibleAll)); } // Initialise one group (top row) Keys <int> group = new Keys <int>(); for (int i = 1; i < 10; i++) { group.Add(i); } IPuzzle <int> puzzle = new PuzzleBase <int>(space); IPuzzleEngine <int> engine = new PuzzleEngine <int>(puzzle); // Action Possible values2To9 = new Possible(possibleAll); values2To9.Remove(1); Keys <int> keysInner = new Keys <int>(); for (int j = 2; j < 10; j++) { keysInner.Add(j); space[j] = new Possible(values2To9); } int jobsAdded = ConstraintMutuallyExclusive <int> .CreateCompleteSetActions(keysInner, group, engine); Assert.AreEqual(1, engine.Count); // Test Keys <int> expectedK = new Keys <int>() { 1 }; IPossible expectedV = new Possible() { 2, 3, 4, 5, 6, 7, 8, 9 }; IJobFilter <int> job = engine.Peek() as IJobFilter <int>; Keys <int> actual = job.Keys; IPossible filter = job.Filter; Assert.AreEqual(1, actual.Count(), "Algorithm Eliminate did not return 8 changes"); Assert.IsTrue(expectedK.SetEquals(actual)); Assert.AreEqual(8, filter.Count, "Filter value incorrect"); Assert.IsTrue(expectedV.SetEquals(filter), "Filter values incorrect"); }