public IEnumerable <Specialist.Model.Specialist> GetSpecialistById(int id)
        {
            SpecialistContext        context = HttpContext.RequestServices.GetService(typeof(SpecialistContext)) as SpecialistContext;
            GetSpecialistByIdHandler handler = new GetSpecialistByIdHandler(context);

            return(handler.Handle(id));
        }
예제 #2
0
        public MedicalSpecialist GetMedicalSpecialistById(int id)
        {
            SpecialistContext        context = HttpContext.RequestServices.GetService(typeof(SpecialistContext)) as SpecialistContext;
            GetSpecialistByIdHandler handler = new GetSpecialistByIdHandler(context);

            return(handler.Handle(id));
        }
        public void GetCourseByIdTest()
        {
            // arrange
            List <MedicalSpecialist> list = new List <MedicalSpecialist>();

            int id = 2;

            MedicalSpecialist expected = new MedicalSpecialist
            {
                LastName     = "lastname",
                FirstName    = "name",
                MiddleName   = "middlename",
                Email        = "*****@*****.**",
                PasswordHash = "password",
                HealthFacilitiesFacultyId = 1,
            };

            //act
            SpecialistContext        context = new SpecialistContext(connString);
            GetSpecialistByIdHandler handler = new GetSpecialistByIdHandler(context);

            handler.Handle(id);

            using (conn = new MySqlConnection(connString))
            {
                conn.Open();
                string query = string.Format("select * from specialists where email='*****@*****.**' and last_name='lastname'");

                MySqlCommand cmd = new MySqlCommand(query, conn);


                using (var reader = cmd.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        list.Add(new MedicalSpecialist()
                        {
                            Id         = Convert.ToInt32(reader["specialist_id"]),
                            LastName   = reader["last_name"].ToString(),
                            FirstName  = reader["first_name"].ToString(),
                            MiddleName = reader["middle_name"].ToString(),
                            Email      = reader["email"].ToString(),
                            HealthFacilitiesFacultyId = Convert.ToInt32(reader["Health_Facilities_faculty_id"]),
                        });
                    }
                }
            }

            if (list[0].HealthFacilitiesFacultyId == expected.HealthFacilitiesFacultyId &&
                list[0].LastName == expected.LastName && list[0].Email == expected.Email)
            {
                Assert.IsTrue(true);
            }
        }