public void EditWord_ShouldEditExistingWordAndReturnTrue() { string newWord = "lab"; RequestedWord = "labas"; WordEntity oldWordEntity = new WordEntity() { Id = 1, Word = "labas", SortedWord = "aabls" }; _wordRepository.GetByWord(RequestedWord).Returns(oldWordEntity); var result = _modificationService.EditWord(oldWordEntity.Word, newWord); _wordRepository.Received().GetByWord(RequestedWord); _wordRepository.Received().Update(oldWordEntity); result.ShouldBeTrue(); }
public IActionResult Edit(string oldWord = "", string newWord = " ") { if (!(string.IsNullOrWhiteSpace(oldWord) && string.IsNullOrWhiteSpace(newWord))) { string ipAddress = HttpContext.Connection.RemoteIpAddress.ToString(); bool editedCorrectly = _modificationService.EditWord(oldWord, newWord); if (editedCorrectly) { _userService.IncrementCounter(ipAddress); ViewBag.Message = "Word edited"; } ViewBag.Message = "Error occured"; } return(View()); }