Example #1
0
        public void DIngredient_WhenAskedForKey_ReturnsEmail_ID()
        {
            //Arrange: An ingredient with a unique key is constructed.
            DIngredient ingredient = new DIngredient { Ingredient_ID = -1 };

            //Act: the key is retrieved.
            int key = ingredient.key;

            //Assert: the key is the same as the friended user's ID.
            Assert.AreEqual(key, ingredient.Ingredient_ID);
        }
Example #2
0
        public void DIngredientWithSqlMembers_WhenScrubbed_BecomesSafe()
        {
            //Arrange: An ingredient with malicious html and sql members is constructed.
            string malicious = "1');DELETE TABLE dbo.example;--";
            DIngredient ingredient = new DIngredient{
                Long_Name = malicious
            };

            //Act: The friended user is scrubbed.
            ingredient.Scrub();

            //Assert: The friended user has no html in its members.
            Assert.AreNotEqual(malicious, ingredient.Long_Name);
        }
Example #3
0
        public void DIngredientWithHtmlMembers_WhenScrubbed_BecomesSafe()
        {
            //Arrange: An ingredient with malicious sql members is constructed.
            string malicious = "<div></div>";
            DIngredient ingredient = new DIngredient{
                Long_Name = malicious
            };

            //Act: The friended user is scrubbed.
            ingredient.Scrub();

            //Assert: The friended user has no html in its members.
            Assert.AreNotEqual(malicious, ingredient.Long_Name);
        }
Example #4
0
        public IEnumerable<DDrink> Ingredient_Update(DIngredient updating, string username)
        {
            IDataRepository<DDrink> drinks =
                RepositoryFactory.Instance.Construct<DDrink>(username);
            IDataRepository<DIngredient> ingredients;

            if((ingredients = drinks.FirstOrDefault(x => x.Drink_ID == updating.Drink_ID)
                .ingredients as IDataRepository<DIngredient>) != null){
                //Drinks for ingredient does belong to given user.
                ingredients.Update(updating);
            }
            return drinks;
        }
Example #5
0
 public ActionResult Ingredient_Update(DIngredient updating)
 {
     return View("Index");
 }
Example #6
0
 public ActionResult Ingredient_Delete(DIngredient deleting)
 {
     return View("Index");
 }
Example #7
0
 public ActionResult Ingredient_Create(DIngredient creating)
 {
     return View("Index");
 }