Beispiel #1
0
        public void GetGenreById_ExistedGameId_GameReturned()
        {
            _uow.Setup(uow => uow.Genres.GetById(_fakeGenreId)).Returns(_fakeGenre);

            var resultGame = _sut.GetById(_fakeGenreId);

            Assert.True(resultGame.Id == _fakeGenreId);
        }
Beispiel #2
0
        void DeleteGenre()
        {
            Console.Write("Enter Id = ");
            int   id = Convert.ToInt32(Console.ReadLine());
            Genre g  = genreService.GetById(id);

            if (genreService.DeleteGenre(g.Id) > 0)
            {
                Console.WriteLine($"Genre {g.Name} deleted successfully");
            }
            else
            {
                Console.WriteLine("Some error has occurred");
            }
        }
Beispiel #3
0
        void DeleteGenre()
        {
            Console.Write("Enter Genre Id = ");
            int   id = Convert.ToInt32(Console.ReadLine());
            Genre g  = genreService.GetById(id);

            if (genreService.DeleteGenre(id) > 0)
            {
                Console.WriteLine($"Genre Id: {id} Name: {g.Name} deleted");
            }
            else
            {
                Console.WriteLine("Some error occurred");
            }
        }
Beispiel #4
0
        public ActionResult <GenreDto> GetById([FromRoute] int id)
        {
            var result = genreService.GetById(id);

            if (result == null)
            {
                return(NotFound());
            }
            return(Ok(result));
        }
Beispiel #5
0
        public void CallRepositoryGetById_WhenInvoked()
        {
            var repositoryMock = new Mock <IEfRepository <Genre> >();
            var unitOfWorkMock = new Mock <IUnitOfWork>();
            var datetimeMock   = new Mock <IDateTimeProvider>();
            var service        = new GenreService(repositoryMock.Object, unitOfWorkMock.Object, datetimeMock.Object);
            var guid           = new Guid("05fababb-f897-49ef-b42a-4943fcc38148");

            service.GetById(guid);

            repositoryMock.Verify(r => r.GetById(guid), Times.Once);
        }
Beispiel #6
0
        public IActionResult EditGenre(long?id)
        {
            if (!id.HasValue)
            {
                return(Error());
            }
            var genre = _genreService.GetById(id.Value);

            if (genre == null)
            {
                return(Error());
            }

            var genreVM = new GenreViewModel()
            {
                Id     = genre.Id,
                Name   = genre.Name,
                Parent = genre.Parent
            };

            ViewBag.Genres = _genreService.GetAll().Select(g => g.Name);
            return(View("EditGenre", genreVM));
        }
Beispiel #7
0
        public void ReturnCorrectGenre_WhenInvoked()
        {
            var genre1         = new Genre("Rock");
            var guid           = new Guid("05fababb-f897-49ef-b42a-4943fcc38148");
            var repositoryMock = new Mock <IEfRepository <Genre> >();
            var unitOfWorkMock = new Mock <IUnitOfWork>();
            var datetimeMock   = new Mock <IDateTimeProvider>();
            var service        = new GenreService(repositoryMock.Object, unitOfWorkMock.Object, datetimeMock.Object);

            repositoryMock.Setup(r => r.GetById(guid)).Returns(genre1);

            var result = service.GetById(guid);

            Assert.AreEqual(genre1, result);
        }
Beispiel #8
0
        public PLGenre GetById(int id)
        {
            //check id
            if (!PLValidation.ValidateId(id))
            {
                return(null);
            }
            var resultBLL = _curGenrelWorkerService.GetById(id);

            if (resultBLL != null)
            {
                PLGenre resultPL = new PLGenre {
                    Id = resultBLL.Id, GenreName = resultBLL.GenreName, Description = resultBLL.Description
                };
                return(resultPL);
            }
            return(null);
        }
Beispiel #9
0
 public GenreDto GetById(int genreId)
 {
     return(genreService.GetById(genreId));
 }
 public void GetById_NullArgument_Exception()
 {
     using var genreService = new GenreService(_mockGenreRepository.Object, _mapper);
     Assert.ThrowsAsync <CustomException>(() => genreService.GetById(null, It.IsAny <string>()));
 }
 public void GetById_BadArgument_ReturnNull_Exception()
 {
     _mockGenreRepository.Setup(w => w.GetById(It.IsAny <string>())).ReturnsAsync(() => null);
     using var genreService = new GenreService(_mockGenreRepository.Object, _mapper);
     Assert.ThrowsAsync <CustomException>(() => genreService.GetById("123", It.IsAny <string>()));
 }
 public void GetById_GoodArgument_Success()
 {
     _mockGenreRepository.Setup(w => w.GetById(It.IsAny <string>())).ReturnsAsync(_genre);
     using var genreService = new GenreService(_mockGenreRepository.Object, _mapper);
     Assert.That(genreService.GetById("123", It.IsAny <string>()).Result, Is.TypeOf(typeof(GenreListingModel)));
 }
Beispiel #13
0
 public Genre GetById(int id)
 {
     return(_genreService.GetById(id));
 }
Beispiel #14
0
        public IActionResult Details(int ID)
        {
            var result = _genderService.GetById(ID);

            return(View(result));
        }