public void Question_1_3_InPlace_EdgeCases() { TestHelpers.AssertExceptionThrown(() => Question_1_3.EscapeStringInplace(null, 0), typeof(ArgumentException)); TestHelpers.AssertExceptionThrown(() => Question_1_3.EscapeStringInplace(" ".ToCharArray(), -1), typeof(ArgumentException)); this.ValidateResultInPlace("", ""); }
private void ValidateResultInPlace(string expected, string input, int?inputLength = null) { var length = inputLength ?? input.TrimEnd(' ').Length; var charArray = input.ToCharArray(); Question_1_3.EscapeStringInplace(charArray, length); Assert.AreEqual(expected, string.Concat(charArray)); }