public async void AuthorService_ShouldReturnExceptionIfNotFound() { //arrange int authorId = 1; var MoqlibraryRespository = new Mock <ILibraryRepository>(); var authorEntity = new AuthorEntity() { Id = 1, Age = 22, Name = "blalfal" }; MoqlibraryRespository.Setup(m => m.GetAuthorAsync(authorId, false)).Returns(Task.FromResult(authorEntity)); var myProfile = new LibraryProfile(); var configuration = new MapperConfiguration(cfg => cfg.AddProfile(myProfile)); var mapper = new Mapper(configuration); var authorService = new AuthorsService(MoqlibraryRespository.Object, mapper); //act await Assert.ThrowsAsync <NotFoundItemException>(() => authorService.GetAuthorAsync(1, false)); }