protected void Page_Load(object sender, EventArgs e)
        {
            if (!this.IsPostBack)
            {
                var topDishesEventArgs = new TopDishesEventArgs(3, true);
                this.GetTopDishes?.Invoke(null, topDishesEventArgs);

                this.TopDishesRepeater.DataSource = this.Model.TopDishes;
                this.TopDishesRepeater.DataBind();
            }
        }
        public void ShouldThrowArgumentExceptionWithCorrectMessage_WhenTopDishesEventArgsDishesCountPropertyIsNegative(int invalidDishesCount)
        {
            var topDishesView = new Mock <ITopDishesView>();
            var dishesService = new Mock <IDishesAsyncService>();

            var topDishesPresenter = new TopDishesPresenter(topDishesView.Object, dishesService.Object);

            var topDishesEventArgs = new TopDishesEventArgs(invalidDishesCount, true);

            Assert.That(
                () => topDishesPresenter.OnGetTopDishes(null, topDishesEventArgs),
                Throws.InstanceOf <ArgumentException>().With.Message.Contains("dishesCount parameter must be greater than or equal to 0."));
        }
        public void InvokeIDishesAsyncService_GetTopCountDishesByRatingMethodOnceWithCorrectAddSampleDataValue(bool addSampleData)
        {
            var topDishesView = new Mock <ITopDishesView>();

            topDishesView.SetupGet(view => view.Model).Returns(new TopDishesViewModel());

            var dishesService = new Mock <IDishesAsyncService>();

            var topDishesPresenter = new TopDishesPresenter(topDishesView.Object, dishesService.Object);

            var topDishesEventArgs = new TopDishesEventArgs(3, addSampleData);

            topDishesPresenter.OnGetTopDishes(null, topDishesEventArgs);

            dishesService.Verify(service => service.GetTopCountDishesByRating(It.IsAny <int>(), addSampleData), Times.Once);
        }
        public void InvokeIDishesAsyncService_GetTopCountDishesByRatingMethodOnceWithCorrectDishesCountValue(int dishesCount)
        {
            var topDishesView = new Mock <ITopDishesView>();

            topDishesView.SetupGet(view => view.Model).Returns(new TopDishesViewModel());

            var dishesService = new Mock <IDishesAsyncService>();

            var topDishesPresenter = new TopDishesPresenter(topDishesView.Object, dishesService.Object);

            var topDishesEventArgs = new TopDishesEventArgs(dishesCount, true);

            topDishesPresenter.OnGetTopDishes(null, topDishesEventArgs);

            dishesService.Verify(service => service.GetTopCountDishesByRating(dishesCount, It.IsAny <bool>()), Times.Once);
        }