public void FindVowelTest() { var request = new VowelCounterRequest(); request.Word = "yellow"; VowelCounterCalculator response = new VowelCounterCalculator(); var output = response.FindVowels(request); Assert.AreEqual(output.VowelCount, 2); }
public VowelCounterResponse FindVowels(VowelCounterRequest request) { var response = new VowelCounterResponse(); for (int i = 0; i < request.Word.Length; i++)//behaves like a foreach loop { if (request.Word[i] == 'a' || request.Word[i] == 'i' || request.Word[i] == 'o' || request.Word[i] == 'u' || request.Word[i] == 'e') { request.Count++; } } response.VowelCount = request.Count; return(response); }
public ActionResult VowelCounterInput(VowelCounterModel request) { if (ModelState.IsValid) { var vowelFind = new VowelCounterCalculator(); var vowelData = new VowelCounterRequest(); vowelData.Word = request.Word; var result = vowelFind.FindVowels(vowelData); return(View("VowelCounterOutput", result)); } else { return(View(request)); } }