public void TeacherCreateTest() { ml.CreateTeachers(new Teachers() { Teacher_Id = 4, School_Id = 2, Name = "Lakatos Franciska", Salary = 600, StartYear = 2019, WellLiked = true, CourseNumber = 25, HealthCare = "f****d" }); mockteacherrepo.Verify(v => v.Create(It.IsAny <Teachers>())); }
/// <summary> /// You can select Teachers CRUD methods here. /// </summary> /// <param name="ml">Business Logic.</param> /// <param name="fields">Field names of the selected table.</param> private static void MenuLowerLayerTeachers(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); Teachers t = new Teachers { Teacher_Id = int.Parse(createTemp.ElementAt(0)), School_Id = int.Parse(createTemp.ElementAt(1)), Name = createTemp.ElementAt(2), Salary = int.Parse(createTemp.ElementAt(3)), StartYear = int.Parse(createTemp.ElementAt(4)), WellLiked = bool.Parse(createTemp.ElementAt(5)), CourseNumber = int.Parse(createTemp.ElementAt(6)), HealthCare = createTemp.ElementAt(7), }; ml.CreateTeachers(t); break; case "2": int id = IDGather(); var readTemp = ml.ReadTeachers(id); Console.WriteLine(readTemp.Teacher_Id + " | " + readTemp.School_Id + " | " + readTemp.Name + " | " + readTemp.Salary + " | " + readTemp.StartYear + " | " + readTemp.WellLiked + " | " + readTemp.CourseNumber + " | " + readTemp.HealthCare); break; case "3": var ownerLogicTemp = ml.ReadAllTeachers(); foreach (var item in ownerLogicTemp) { Console.WriteLine(item.Teacher_Id + " | " + item.School_Id + " | " + item.Name + " | " + item.Salary + " | " + item.StartYear + " | " + item.WellLiked + " | " + item.CourseNumber + " | " + item.HealthCare); } Console.Write("Press any button to continue..."); Console.ReadLine(); break; case "4": var updateTemp = DataGather(fields.Count, fields); Teachers t2 = new Teachers { Teacher_Id = int.Parse(updateTemp.ElementAt(0)), School_Id = int.Parse(updateTemp.ElementAt(1)), Name = updateTemp.ElementAt(2), Salary = int.Parse(updateTemp.ElementAt(3)), StartYear = int.Parse(updateTemp.ElementAt(4)), WellLiked = bool.Parse(updateTemp.ElementAt(5)), CourseNumber = int.Parse(updateTemp.ElementAt(6)), HealthCare = updateTemp.ElementAt(7), }; ml.UpdateTeachers(t2); break; case "5": var deleteTemp = IDGather(); ml.DeleteTeachers(deleteTemp); break; } }