Ejemplo n.º 1
0
 public void GetByBook_GoodArgument_Success()
 {
     _genres.Add(new Genre
     {
         Id       = Guid.NewGuid().ToString(),
         Name     = "SomeGenreName",
         ImageUrl = "SomeImageUrl",
         Books    = new List <GenreBook>
         {
             new GenreBook
             {
                 Book    = new Book(),
                 Id      = Guid.NewGuid().ToString(),
                 Genre   = new Genre(),
                 BookId  = "123",
                 GenreId = Guid.NewGuid().ToString()
             }
         },
         Likes = new List <GenreLike>()
     });
     _mockGenreRepository.Setup(w => w.GetAll()).ReturnsAsync(_genres);
     _mockGenreRepository.Setup(w => w.GetById(It.IsAny <string>())).ReturnsAsync(_genre);
     using var genreService = new GenreService(_mockGenreRepository.Object, _mapper);
     Assert.That(genreService.GetByBook("123", It.IsAny <string>()).Result, Is.TypeOf(typeof(List <GenreListingModel>)));
 }
Ejemplo n.º 2
0
 public void GetByBook_NullArgument_Exception()
 {
     using var genreService = new GenreService(_mockGenreRepository.Object, _mapper);
     Assert.ThrowsAsync <CustomException>(() => genreService.GetByBook(null, It.IsAny <string>()));
 }
Ejemplo n.º 3
0
 public void GetByBook_BadArgument_ReturnNull_Exception()
 {
     _mockGenreRepository.Setup(w => w.GetAll()).ReturnsAsync(_genres);
     using var genreService = new GenreService(_mockGenreRepository.Object, _mapper);
     Assert.ThrowsAsync <CustomException>(() => genreService.GetByBook("123", It.IsAny <string>()));
 }