public void EditWord_GivenWordEditModelWithUniqueNewWord_ShouldChangeOriginalWordToNewWord() { WordEditInfoModel wordEditInfoModel = new WordEditInfoModel { OriginalWord = "sula", NewWord = "alus" }; _wordRepository.EditWord(wordEditInfoModel.OriginalWord, wordEditInfoModel.NewWord).Returns(true); _userContract.GetUser("10").Returns(new User { Id = 10, UserIp = "10", SearchesLeft = 10 }); _userContract.GetUser("127.0.0.1").Returns(new User { Id = 1, UserIp = "127.0.0.1", SearchesLeft = 10 }); var result = _dictionaryManagingService.EditWord(wordEditInfoModel, "10"); _userManagingService.Received().GiveUserAdditionalSearch("127.0.0.1"); result.NewWord.ShouldBeNull(); result.OriginalWord.ShouldBe("alus"); result.EditStatus.ShouldBe(WordEditStatus.EditSuccessful); }
public IActionResult EditWord(string originalWord, string newWord) { WordEditInfoModel wordEditInfoModel = new WordEditInfoModel(); wordEditInfoModel.OriginalWord = originalWord; wordEditInfoModel.NewWord = newWord; if (String.IsNullOrEmpty(wordEditInfoModel.NewWord)) { return(View(wordEditInfoModel)); } wordEditInfoModel = _dictionaryManagaingService.EditWord(wordEditInfoModel, HttpContext.Connection.LocalIpAddress.ToString()); return(View(wordEditInfoModel)); }