コード例 #1
0
        public void ShouldBeAbleToAddNewMeal()
        {
            //Arrange
            var meal = CreateMeal(0, USER, DateTime.Today);

            mealController.Stub(x => x.GetAllMeals(Arg <User> .Is.Anything)).Return(new List <Meal>());
            mealDao.Stub(x => x.AddMeal(Arg <Meal> .Is.Anything)).Return(true);

            //Act
            bool actual = mealController.AddMeal(meal);

            //Assert
            Assert.IsTrue(actual);
        }
コード例 #2
0
 private void btnSaveMeal_Click(object sender, EventArgs e)
 {
     try
     {
         if (ValidateController())
         {
             Meal meal = new Meal()
             {
                 Date = dateTimePicker1.Value,
                 Id   = mealController.GetNextId(),
                 User = user
             };
             meal.Foods = GetAllFoods(meal.Id);
             if (mealController.AddMeal(meal))
             {
                 MessageBox.Show(Resources.MealAddedWithSuccess, TitleFactory.GetTitle(this.GetType()),
                                 MessageBoxButtons.OK, MessageBoxIcon.Error);
             }
         }
     }
     catch (Exception ex)
     {
         MessageBoxErrorType(ex.Message);
     }
 }
コード例 #3
0
    /// <summary>
    /// This button on click method is for adding a new Meal to the database.
    /// Added April 13. Modification of Meal's Add method.
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void AddMealButton_Click(object sender, EventArgs e)
    {
        //finding the customer profile choice to display
        string addItem = AddMealsTextBox.Text.Trim();
        int    userID  = Convert.ToInt32(Session["adminID"]);

        MessageUserControl.TryRun(() =>
        {
            MealController sysmgr = new MealController();

            sysmgr.AddMeal(addItem, userID);
            MealsListView.DataBind();
            AddMealsTextBox.Text = "";
        }, "Success", "Successfully added the new meal: \"" + addItem + "\"");
    }