Esempio n. 1
0
        public void AddInstruction()
        {
            //create a new cooking instruction
            var instruction = new CookingInstruction()
            {
                Name        = "Prepare The Chicken",
                Instruction = "Cut the chicken into small cubes"
            };

            //add the cooking instruction to the database
            cookingInstructionRepository.Add(instruction);

            var foundInstruction = cookingInstructionRepository.GetAll().ToList();

            if (foundInstruction != null)
            {
                Assert.AreEqual(1, foundInstruction.Count());
                Assert.AreEqual(foundInstruction[0].Name, instruction.Name);
                Assert.AreEqual(foundInstruction[0].Instruction, instruction.Instruction);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Method to add a cooking instruction
        /// </summary>
        /// <param name="instruction">The recipe to be added</param>
        /// <returns>True if it was added</returns>
        public async Task <bool> AddCookingInstructionAsync(CookingInstructionDTO instruction)
        {
            var isAdded = true;

            try
            {
                var instructionToBeAdded = CreateInstructionEntity(instruction);
                await Task.Run(() => cookingInstructionRepository.Add(instructionToBeAdded));
            }
            catch (Exception ex)
            {
                isAdded = false;
                // TODO:Add logging
            }

            return(isAdded);
        }