public LowercaseResponse ProcessRequest(LowercaseRequest request) { LowercaseResponse response = new LowercaseResponse(); HelperFunctions helper = new HelperFunctions(); String changeString = request.stringToModify; if (request.firstCharOnly) { int count = 0; //Find the total amount of white spaces for (int i = 0; i < changeString.Length; i++) { if (changeString[i] == ' ') { count++; } else { break; } } changeString = changeString.TrimStart(); Console.WriteLine(changeString); if (changeString.Length >= 1) { char changeStringChar = changeString[0]; changeStringChar = Char.ToLower(changeStringChar); changeString = changeString.Remove(0, 1); changeString = changeString.Insert(0, changeStringChar.ToString()); } for (int x = 0; x < count; x++) { //reinsert white spaces changeString = changeString.Insert(0, " "); //changeString = " " + changeString; } } else { changeString = changeString.ToLower(); } if (request.trimPrecedingWhiteSpace) { changeString = changeString.TrimStart(); } if (request.trimTrailingWhiteSpace) { changeString = changeString.TrimEnd(); } response.modifiedString = changeString; response.originalString = request.stringToModify; return(response); }
public void ProcessRequestFirstChar() { //arrange request.stringToModify = "TEST STRING"; request.firstCharOnly = true; request.trimPrecedingWhiteSpace = false; request.trimTrailingWhiteSpace = false; //act response = cap.ProcessRequest(request); //assert Assert.AreEqual("tEST STRING", response.modifiedString); }
public void Setup() { request = new LowercaseRequest(); cap = new Lowercase(); response = new LowercaseResponse(); }