コード例 #1
0
        public void SchoolCreateTest()
        {
            ml.CreateSchools(new Schools()
            {
                School_Id        = 4,
                City             = "El Salvador",
                ZipCode          = 8300,
                Address          = "Gun street 3",
                Country          = "San Salvador",
                NumberOfChildren = 30
            });

            mockschoolrepo.Verify(v => v.Create(It.IsAny <Schools>()));
        }
コード例 #2
0
        /// <summary>
        /// You can select Schools CRUD methods here.
        /// </summary>
        /// <param name="ml">Business Logic.</param>
        /// <param name="fields">Field names of the selected table.</param>
        private static void MenuLowerLayerSchools(MainLogic ml, List <string> fields)
        {
            Console.Clear();
            Console.WriteLine("What do you want to do?");
            Console.WriteLine("[1] Create");
            Console.WriteLine("[2] Read");
            Console.WriteLine("[3] ReadAll");
            Console.WriteLine("[4] Update");
            Console.WriteLine("[5] Delete");
            Console.WriteLine();
            Console.Write("Your choice: ");
            string crudchoice = Console.ReadLine();

            Console.Clear();
            switch (crudchoice)
            {
            case "1":
                List <string> createTemp = DataGather(fields.Count, fields);
                Schools       s          = new Schools
                {
                    School_Id        = int.Parse(createTemp.ElementAt(0)),
                    Country          = createTemp.ElementAt(1),
                    City             = createTemp.ElementAt(2),
                    ZipCode          = int.Parse(createTemp.ElementAt(3)),
                    Address          = createTemp.ElementAt(4),
                    NumberOfChildren = int.Parse(createTemp.ElementAt(5)),
                };
                ml.CreateSchools(s);
                break;

            case "2":
                int id       = IDGather();
                var readTemp = ml.ReadSchools(id);
                Console.WriteLine("\n" + readTemp.School_Id + " | " + readTemp.Country + " | " + readTemp.City + " | " + readTemp.ZipCode + " | " + readTemp.Address + " | " + readTemp.NumberOfChildren);
                break;

            case "3":
                var schoolLogicTemp = ml.ReadAllSchools();
                foreach (var item in schoolLogicTemp)
                {
                    Console.WriteLine(item.School_Id + " | " + item.Country + " | " + item.City + " | " + item.ZipCode + " | " + item.Address + " | " + item.NumberOfChildren);
                }

                Console.Write("Press any button to continue...");
                Console.ReadLine();
                break;

            case "4":
                var     updateTemp = DataGather(fields.Count, fields);
                Schools s2         = new Schools
                {
                    School_Id        = int.Parse(updateTemp.ElementAt(0)),
                    Country          = updateTemp.ElementAt(1),
                    City             = updateTemp.ElementAt(2),
                    ZipCode          = int.Parse(updateTemp.ElementAt(3)),
                    Address          = updateTemp.ElementAt(4),
                    NumberOfChildren = int.Parse(updateTemp.ElementAt(5)),
                };
                ml.UpdateSchools(s2);
                break;

            case "5":
                var deleteTemp = IDGather();
                ml.DeleteSchools(deleteTemp);
                break;
            }
        }