public void Should_Throw_Exception_Trying_To_Delete_Non_Existing_Word(int wordId, string userIp) { _wordsRepository.GetWords().Returns(_dummyWordsRepository.GetWords()); _wordsRepository .When(x => x.DeleteWord(wordId)) .Do(x => { if (!_wordsRepository.GetWords().Any(w => w.Id == wordId)) { throw new Exception(); } }); Assert.Throws <Exception>(() => _dictionaryService.DeleteWord(wordId, userIp)); }