コード例 #1
0
        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);
            }
        }
コード例 #2
0
        public CrewMember Create(Department department, int id)
        {
            CrewMember member;

            switch (department)
            {
            case Department.Science:
                member = new ScienceSpecialist(id);
                break;

            case Department.Engineering:
                member = new MaintenanceTechnician(id);
                break;

            case Department.Medical:
                member = new MedicalSpecialist(id);
                break;

            case Department.Operations:
                member = new OperationsSpecialist(id);
                break;

            case Department.Tactical:
                member = new TacticalSpecialist(id);
                break;

            case Department.Command:
                member = new Commander(id);
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(department), department, null);
            }

            member.Department = department;

            return(member);
        }