public void ShouldInvokeAsyncRepository_GetTopCountDishesByRatingMethodOnceWithCorrectParameter(int dishesCount)
        {
            var asyncRepository = new Mock <IDishesAsyncRepository>();

            asyncRepository.Setup(repo => repo.GetTopCountDishesByRating(It.IsAny <int>())).Returns(Task.Run <ICollection <NamePhotoRatingDishViewDTO> >(() => new List <NamePhotoRatingDishViewDTO>()));

            var unitOfWorkFactory = new Mock <IDisposableUnitOfWorkFactory>();
            var usersRepository   = new Mock <IUsersAsyncRepository>();
            var dishFactory       = new Mock <IInitializedDishFactory>();
            var videoItemFactory  = new Mock <IInitializedVideoItemFactory>();
            var photoItemFactory  = new Mock <IInitializedPhotoItemFactory>();

            var dishesAsyncService = new DishesAsyncService(asyncRepository.Object, usersRepository.Object, dishFactory.Object, videoItemFactory.Object, photoItemFactory.Object, unitOfWorkFactory.Object);

            dishesAsyncService.GetTopCountDishesByRating(dishesCount, false);

            asyncRepository.Verify(repo => repo.GetTopCountDishesByRating(dishesCount), Times.Once);
        }
        public void ShouldThrowArgumentExceptionWithCorrectMessage_WhenDishesCountParameterIsNegative(int dishesCount)
        {
            var asyncRepository = new Mock <IDishesAsyncRepository>();

            asyncRepository.Setup(repo => repo.GetTopCountDishesByRating(It.IsAny <int>())).Returns(Task.Run <ICollection <NamePhotoRatingDishViewDTO> >(() => new List <NamePhotoRatingDishViewDTO>()));

            var unitOfWorkFactory = new Mock <IDisposableUnitOfWorkFactory>();
            var usersRepository   = new Mock <IUsersAsyncRepository>();
            var dishFactory       = new Mock <IInitializedDishFactory>();
            var videoItemFactory  = new Mock <IInitializedVideoItemFactory>();
            var photoItemFactory  = new Mock <IInitializedPhotoItemFactory>();

            var dishesAsyncService = new DishesAsyncService(asyncRepository.Object, usersRepository.Object, dishFactory.Object, videoItemFactory.Object, photoItemFactory.Object, unitOfWorkFactory.Object);

            Assert.That(
                () => dishesAsyncService.GetTopCountDishesByRating(dishesCount, false),
                Throws.InstanceOf <ArgumentException>().With.Message.Contains("dishesCount parameter must be greater than or equal to 0."));
        }
        public void ShouldReturnCorrectType_WhenParameteresAreCorrect()
        {
            var asyncRepository = new Mock <IDishesAsyncRepository>();

            asyncRepository.Setup(repo => repo.GetTopCountDishesByRating(It.IsAny <int>())).Returns(Task.Run <ICollection <NamePhotoRatingDishViewDTO> >(() => new List <NamePhotoRatingDishViewDTO>()));

            var unitOfWorkFactory = new Mock <IDisposableUnitOfWorkFactory>();
            var usersRepository   = new Mock <IUsersAsyncRepository>();
            var dishFactory       = new Mock <IInitializedDishFactory>();
            var videoItemFactory  = new Mock <IInitializedVideoItemFactory>();
            var photoItemFactory  = new Mock <IInitializedPhotoItemFactory>();

            var dishesAsyncService = new DishesAsyncService(asyncRepository.Object, usersRepository.Object, dishFactory.Object, videoItemFactory.Object, photoItemFactory.Object, unitOfWorkFactory.Object);

            var dishesCount  = 3;
            var actualResult = dishesAsyncService.GetTopCountDishesByRating(dishesCount, false);

            Assert.That(actualResult, Is.InstanceOf <IEnumerable <NamePhotoRatingDishViewDTO> >());
        }