public void RestoreStringTests() { ShuffleString obj = new ShuffleString(); string s = "codeleet"; int[] indices = { 4, 5, 6, 7, 0, 2, 1, 3 }; var x = obj.RestoreString(s, indices);//leetcode s = "abc"; indices = new int[] { 0, 1, 2 }; x = obj.RestoreString(s, indices);//abc }
public void RestoreString_WhenCalledWithLCExample5_ReturnsCorrect() { // Arrange ShuffleString = new ShuffleString(); string expected = "art"; string s = "rat"; int[] indicies = { 1, 0, 2 }; // Act string actual = ShuffleString.RestoreString(s, indicies); // Assert Assert.AreEqual(expected, actual); }
public void RestoreString_WhenCalledWithLCExample4_ReturnsCorrect() { // Arrange ShuffleString = new ShuffleString(); string expected = "arigatou"; string s = "aaiougrt"; int[] indicies = { 4, 0, 2, 6, 7, 3, 1, 5 }; // Act string actual = ShuffleString.RestoreString(s, indicies); // Assert Assert.AreEqual(expected, actual); }
public void RestoreString_WhenCalledWithLCExample3_ReturnsCorrect() { // Arrange ShuffleString = new ShuffleString(); string expected = "nihao"; string s = "aiohn"; int[] indicies = { 3, 1, 4, 2, 0 }; // Act string actual = ShuffleString.RestoreString(s, indicies); // Assert Assert.AreEqual(expected, actual); }
public void RestoreString_WhenCalledWithLCExample1_ReturnsCorrect() { // Arrange ShuffleString = new ShuffleString(); string expected = "leetcode"; string s = "codeleet"; int[] indicies = { 4, 5, 6, 7, 0, 2, 1, 3 }; // Act string actual = ShuffleString.RestoreString(s, indicies); // Assert Assert.AreEqual(expected, actual); }
public void TestShuffleString(TestCase testCase) { var shuffleString = new ShuffleString(); var response = new RandomStringResponse(); if (testCase.SolutionType == SolutionType.Simple) { response = shuffleString.OneLinerSimpleSolution(testCase.Request); } else if (testCase.SolutionType == SolutionType.Random) { response = shuffleString.UsingRandomSolution(testCase.Request); } else if (testCase.SolutionType == SolutionType.ThreadSafe) { response = shuffleString.ThreadSafeUsingFisherYatesSolution(testCase.Request); } Assert.AreEqual(response.Success, testCase.Success); Assert.AreNotEqual(response.GeneratedRandomString, testCase.Request); }