//----------------------------------------------------------------------------------------------------------------------------------
        /// <summary>
        /// Test functions
        /// </summary>
        public void Add_test(BE.Test test)
        {
            List <BE.Trainee> trainees  = SearchTrainee(test.Traniee_id, true, false, false);
            List <BE.Test>    tests     = SearchTest(test.Traniee_id, false, true, false);
            conditionDelegate condition = (x) => { return(x.Student_car_Type == test.Student_car_Type); };

            //makes sure the student exists
            if (trainees.Count == 0)
            {
                throw new Exception("שגיאה בקבלת נתונים: התלמיד לא קיים במערכת");
            }

            //checks if the student took at least 20 lessons
            if (trainees[0].Num_of_classes < BE.Configuration.Minimun_lessons)
            {
                throw new Exception("שגיאה: התלמיד לא עשה מספיק שיעורים");
            }

            //checks if the date passed
            if (test.Test_time < DateTime.Now)
            {
                throw new Exception("שגיאה בקביעת טסט: התאריך עבר כבר");
            }

            //checks if the student as a test in the last 7 days
            foreach (BE.Test item in tests)
            {
                if ((test.Test_time - item.Test_time) < new TimeSpan(BE.Configuration.Time_between_tests, 0, 0, 0))
                {
                    throw new Exception("שגיאה: אי אפשר לקבוע עוד מבחן תוך זמן כלכך קצר");
                }
            }

            //checks the test to see if the student past the test on the car type
            foreach (BE.Test item in tests)
            {
                if (condition(item) && item.Grade)
                {
                    throw new Exception("שגיאה: עברת כבר מבחן על סוג רכב זה");
                }
                if (condition(item) && item.Criteria_list.Count == 0)
                {
                    throw new Exception("שגיאה: עשית כבר מבחן על סוג רכב זה, חכה לתשובה");
                }
            }

            Func <BE.Test, List <BE.Tester> > find_testers = Find_testers;

            //finds the tester that can work that day
            List <BE.Tester> testers = find_testers(test);

            //if couldnt find any testers he searches for the next time that does have testers
            if (testers.Count == 0)
            {
                DateTime time_new = test.Test_time;
                while (testers.Count == 0)
                {
                    if (time_new.Hour + 1 > 14)
                    {
                        time_new = time_new.AddHours(19);
                    }
                    else
                    {
                        time_new = time_new.AddHours(1);
                    }
                    if (time_new.DayOfWeek == DayOfWeek.Friday)
                    {
                        time_new = time_new.AddDays(2);
                    }

                    test.Test_time = time_new;
                    testers        = find_testers(test);
                }
                // offers a diffrent date for the test
                throw new Exception("שגיאה בקביעת מבחן: לא נמצא בוחן פנוי בזמן המבוקש\nמומלץ לנסות את התאריך - " + time_new.ToString());
            }

            //if found testers takes the first and adds the test to the list
            test.Tester_id = testers[0].ID;
            Dal.Add_test(test);
        }