public async Task GetWordByIDFailedWhenWordWithSuchIdNotFound() { _additionalWordRepoMock.SelectWordById(Arg.Any <int>()).Returns((WordEntity)null); Assert.ThrowsAsync <Exception>( async() => await _wordService.GetWordById(5)); await _additionalWordRepoMock.Received().SelectWordById(Arg.Any <int>()); }
public async Task <Anagram> GetWordById(int?id) { if (id == null) { throw new Exception("Id not defined"); } var wordEntity = await _additionalWordRepository.SelectWordById((int)id); if (wordEntity == null) { throw new Exception("No word with sepcified Id"); } var model = _mapper.Map <Anagram>(wordEntity); return(model); }