public void TestCyclicRotation() { Assert.AreEqual(string.Join(",", CyclicRotation.Solution(new int[] { 1, 2, 3, 4, 5 }, 2)), "4,5,1,2,3"); Assert.AreEqual(string.Join(",", CyclicRotation.Solution(new int[] { 1, 2, 3, 4, 5 }, 0)), "1,2,3,4,5"); Assert.AreEqual(string.Join(",", CyclicRotation.Solution(new int[] { 1 }, 4)), "1"); Assert.AreEqual(string.Join(",", CyclicRotation.Solution(new int[] { }, 2)), ""); }
public void ArrayRotationTest(int[] given, int k, int[] expected) { var target = new CyclicRotation(); var actual = target.solution(given, k); Assert.AreEqual(actual, expected); }
public void ShouldRotateReturnNewRotatedArrayWhenGivenNonEmptyAandK(int[] a, int k, int[] expected) { CyclicRotation rotator = new CyclicRotation(); int[] actual = rotator.Rotate(a, k); Assert.IsTrue(Enumerable.SequenceEqual(expected, actual)); }
public void RotateMyArray(int[] expected, int[] input, int rotate) { CyclicRotation cyclicRotation = new CyclicRotation(); int[] output = new int[input.Length]; output = cyclicRotation.RotateArray(input, rotate); Assert.Equal(expected, output); }
public void CyclicRotationSolutionTestWithNegativeValues() { CyclicRotation testRotation = new CyclicRotation(); int[] arrayTest = new int[] { 1, -2, 3, -4 }; int[] result = new int[] { 1, -2, 3, -4 }; Assert.IsTrue(result.SequenceEqual(testRotation.Solution(arrayTest, 4))); }
public void CyclicRotationSolutionTestWith1Rotation() { CyclicRotation testRotation = new CyclicRotation(); int[] arrayTest = new int[] { 0, 0, 0 }; int[] result = new int[] { 0, 0, 0 }; Assert.IsTrue(result.SequenceEqual(testRotation.Solution(arrayTest, 1))); }
public void CyclicRotationSolutionTest() { CyclicRotation testRotation = new CyclicRotation(); int[] arrayTest = new int[] { 3, 8, 9, 7, 6 }; int[] result = new int[] { 9, 7, 6, 3, 8 }; Assert.IsTrue(result.SequenceEqual(testRotation.Solution(arrayTest, 3))); }
public void Shift_OddSourceLength_DoRotation(int stepsAmount, int[] expected) { var source = new int[] { 1, 2, 3, 4, 5 }; var rotator = new CyclicRotation(); var result = rotator.Shift(source, stepsAmount); result.Should().BeEquivalentTo(expected); }
public void TestMethod1() { int moves = 3; int[] input = { 3, 8, 9, 7, 6 }; int[] expected = { 9, 7, 6, 3, 8 }; int[] result = CyclicRotation.Solution(input, moves); CollectionAssert.AreEqual(expected, result); }
public void CyclicRotation_Should_Handle_Zero_Value() { CyclicRotation subject = new CyclicRotation(); int[] array = {}; int[] result = subject.solution(array, 0); Assert.Equal(array, result); }
public void CyclicRotationTest_01() { CyclicRotation cr = new CyclicRotation(); int[] array = new int[] { 2, 3, 1, 5 }; var solution = cr.solution(array, 3); var expected = new int[] { 3, 1, 5, 2 }; CollectionAssert.AreEqual(expected, solution); }
public void RotationTest(int[] A, int k, int[] expected) { CyclicRotation rotation = new CyclicRotation(); var result = rotation.Rotate(A, k); for (int index = 0; index < A.Length; index++) { Assert.AreEqual(expected[index], result[index]); } }
public void TestMethod3() { int moves = 4; int[] input = { 1, 2, 3, 4 }; int[] expected = { 1, 2, 3, 4 }; int[] result = CyclicRotation.Solution(input, moves); CollectionAssert.AreEqual(expected, result); }
public void when_num_is_negative_should_return_same() { // Arrange var input = new int[] { 1, 2, 3, 4 }; var output = new int[] { 1, 2, 3, 4 }; //Act var result = CyclicRotation.Solution(input, -1); //Assert CollectionAssert.AreEqual(result, output); }
public void test_CyclicRotation_double() { // Arrange var input = new int[] { 5, -1000 }; var output = new int[] { -1000, 5 }; //Act var result = CyclicRotation.Solution(input, 1); //Assert CollectionAssert.AreEqual(result, output); }
public void when_k_is_greater_than_n() { // Arrange var input = new int[] { 1, 1, 2, 3, 5 }; var output = new int[] { 3, 5, 1, 1, 2 }; //Act var result = CyclicRotation.Solution(input, 42); //Assert CollectionAssert.AreEqual(result, output); }
public void when_array_is_empty() { // Arrange var input = new int[] { }; var output = new int[] { }; //Act var result = CyclicRotation.Solution(input, 1); //Assert CollectionAssert.AreEqual(result, output); }
public void when_array_is_same_number_return_same() { // Arrange var input = new int[] { 0, 0, 0 }; var output = new int[] { 0, 0, 0 }; //Act var result = CyclicRotation.Solution(input, 1); //Assert CollectionAssert.AreEqual(result, output); }
public void test_CyclicRotation_small() { // Arrange var input = new int[] { 1, 2, 3, 4, 5, 6, 7 }; var output = new int[] { 6, 7, 1, 2, 3, 4, 5 }; //Act var result = CyclicRotation.Solution(input, 2); //Assert CollectionAssert.AreEqual(result, output); }
public void SolutionTest_04() { var solution = new CyclicRotation(); int[] A = new int[] { 3, 8, 9, 7, 6 }; int K = 3; int[] expected = new int[] { 9, 7, 6, 3, 8 }; int[] actual = solution.Solution(A, K); Assert.AreEqual(expected, actual); }
public void test_CyclicRotation_by_three() { // Arrange var input = new int[] { 3, 8, 9, 7, 6 }; var output = new int[] { 9, 7, 6, 3, 8 }; //Act var result = CyclicRotation.Solution(input, 3); //Assert CollectionAssert.AreEqual(result, output); }
public void CyclicRotation_Should_Process_Complex_Values() { CyclicRotation subject = new CyclicRotation(); int[] array = { 12, 14, 18, 19, 100, 1999, 345, 1223, 45436, 654654 }; int[] result = subject.solution(array, 15); int[] expectedResult = { 1999, 345, 1223, 45436, 654654, 12, 14, 18, 19, 100 }; Assert.Equal(expectedResult, result); }
public void CyclicRotation_Should_Process_Simple_Values() { CyclicRotation subject = new CyclicRotation(); int[] array = { 1, 2, 3, 4 }; int[] result = subject.solution(array, 1); int[] expectedResult = { 4, 1, 2, 3 }; Assert.Equal(expectedResult, result); }
public void GetArrayRotatedTest() { // Arrange var cyclicRotation = new CyclicRotation(); // Action var arrayRotated = cyclicRotation.GetArrayRotated(new int[] { 3, 8, 9, 7, 6 }, 3); // Assert int[] expected = new int[] { 9, 7, 6, 3, 8 }; CollectionAssert.AreEqual(expected, arrayRotated); }
public void Solution_SmallNumbers_Corect() { //Arrange - Given var array = new int[] { 1, 2, 3, 4 }; var rotations = 2; //Act - When var result = CyclicRotation.Solution(array, rotations); //Assert - Then var expectedResult = new int[] { 3, 4, 1, 2 }; Assert.Equal(expectedResult, result); }
public void SingleRotationTest() { //Arrange int[] array = { 1, 2, 3, 4, 5 }; int rotationTimes = 1; int[] expected = { 5, 1, 2, 3, 4 }; int[] actual = null; //Act actual = CyclicRotation.RotateArray(array, rotationTimes); //Assert Assert.Equal(expected, actual); }
public void ZerosRotationTest() { //Arrange int[] array = { 0, 0, 0 }; int rotationTimes = 1; int[] expected = { 0, 0, 0 }; int[] actual = null; //Act actual = CyclicRotation.RotateArray(array, rotationTimes); //Assert Assert.Equal(expected, actual); }
public void MoreTimesThanArrayLengthRotationTest() { //Arrange int[] array = { 1, 2, 3, 4 }; int rotationTimes = 6; int[] expected = { 3, 4, 1, 2 }; int[] actual = null; //Act actual = CyclicRotation.RotateArray(array, rotationTimes); //Assert Assert.Equal(expected, actual); }
public void SameTimesAsArrayLengthRotationTest() { //Arrange int[] array = { 1, 2, 3, 4, 5 }; int rotationTimes = 5; int[] expected = { 1, 2, 3, 4, 5 }; int[] actual = null; //Act actual = CyclicRotation.RotateArray(array, rotationTimes); //Assert Assert.Equal(expected, actual); }
public void SimpleRotations() { //Arrange var CyclicRotationSolver = new CyclicRotation(); //Act var TestArray = new int[] { 3, 8, 9, 7, 6 }; var RotatedArray = new int[] { 9, 7, 6, 3, 8 }; var rotation = 3; //Test var rotationResult = CyclicRotationSolver.Solution(TestArray, rotation); Assert.AreEqual(rotationResult.Length, RotatedArray.Length); for (int i = 0; i < rotationResult.Length; i++) { Assert.AreEqual(rotationResult[i], RotatedArray[i]); } }