public void Exercise1_Nondecreasing_GivesCorrectPermutationPerIteration() { var initialArray = new[] { 31, 41, 59, 26, 41, 58 }; var algorithm = new InsertionSort.Algorithm.InsertionSort.Nondecreasing(initialArray); using (var permute = algorithm.Permute().GetEnumerator()) { permute.GetNext().ShouldBe(new[] { 31, 41, 59, 26, 41, 58 }); permute.GetNext().ShouldBe(new[] { 31, 41, 59, 26, 41, 58 }); permute.GetNext().ShouldBe(new[] { 26, 31, 41, 59, 41, 58 }); permute.GetNext().ShouldBe(new[] { 26, 31, 41, 41, 59, 58 }); permute.GetNext().ShouldBe(new[] { 26, 31, 41, 41, 58, 59 }); permute.MoveNext().ShouldBe(false); } }
public void Nondecreasing_GivesCorrectPermutationPerIteration() { var initialArray = new [] { 5, 2, 4, 6, 1, 3 }; var algorithm = new InsertionSort.Algorithm.InsertionSort.Nondecreasing(initialArray); using (var permute = algorithm.Permute().GetEnumerator()) { permute.GetNext().ShouldBe(new[] { 2, 5, 4, 6, 1, 3 }); permute.GetNext().ShouldBe(new[] { 2, 4, 5, 6, 1, 3 }); permute.GetNext().ShouldBe(new[] { 2, 4, 5, 6, 1, 3 }); permute.GetNext().ShouldBe(new[] { 1, 2, 4, 5, 6, 3 }); permute.GetNext().ShouldBe(new[] { 1, 2, 3, 4, 5, 6 }); permute.MoveNext().ShouldBe(false); } }