public void TestModifyPatientSuccess()
        {
            // Arrange
            AdminController adminController = new AdminController();
            bool expected = true;

            Patient expectedPatient = new Patient();
            expectedPatient.PatientID = 1;
            expectedPatient.FirstName = "test";
            expectedPatient.LastName = "test";
            expectedPatient.DateOfBirth = new DateTime(1991, 2, 5);
            expectedPatient.Gender = PersonGender.Male;
            expectedPatient.TelephoneNumber = "00000000000";
            expectedPatient.EmailAddress = "test";
            expectedPatient.AddressLine1 = "test";
            expectedPatient.AddressLine2 = "test";
            expectedPatient.City = "test";
            expectedPatient.County = "test";
            expectedPatient.PostCode = "test";
            expectedPatient.MaritalStatus = "married";

            // Act
            bool actual = adminController.ModifyPatient(expectedPatient, 1, "test", "test", 0, "05/02/1991", "married", "00000000000", "test", "test", "test", "test", "test", "test");

            // Assert
            Assert.AreEqual(expected, actual);
        }
        public void TestFindStaffOnSearch()
        {
            // Arrange
            AdminController adminController = new AdminController();
            List<Staff> expectedStaff = new List<Staff>();
            expectedStaff.Add(new Staff());
            expectedStaff[0].StaffID = 1;
            expectedStaff[0].FirstName = "test";
            expectedStaff[0].LastName = "test";
            expectedStaff[0].DateOfBirth = new DateTime(2013, 2, 5);
            expectedStaff[0].Gender = PersonGender.Male;
            expectedStaff[0].TelephoneNumber = "00000000000";
            expectedStaff[0].EmailAddress = "test";
            expectedStaff[0].AddressLine1 = "test";
            expectedStaff[0].AddressLine2 = "test";
            expectedStaff[0].City = "test";
            expectedStaff[0].County = "test";
            expectedStaff[0].PostCode = "test";
            expectedStaff[0].MaritalStatus = "single";
            expectedStaff[0].Permissions = PermissionsFlag.Doctor;

            // Act
            List<Staff> actualStaff = adminController.GetStaffDetails("1", "test", "test");

            // Assert
            CollectionAssert.AreEqual(expectedStaff, actualStaff);
        }
        public void TestStaffOnDuty()
        {
            // Arrange
            AdminController adminController = new AdminController();
            List<Staff> expectedResults = new List<Staff>();
            expectedResults.Add(new Staff());
            expectedResults[0].StaffID = 1;
            expectedResults[0].FirstName = "test";
            expectedResults[0].LastName = "test";
            expectedResults[0].DateOfBirth = new DateTime(2013, 2, 5);
            expectedResults[0].Gender = PersonGender.Male;
            expectedResults[0].TelephoneNumber = "00000000000";
            expectedResults[0].EmailAddress = "test";
            expectedResults[0].AddressLine1 = "test";
            expectedResults[0].AddressLine2 = "test";
            expectedResults[0].City = "test";
            expectedResults[0].County = "test";
            expectedResults[0].PostCode = "test";
            expectedResults[0].MaritalStatus = "single";
            expectedResults[0].Permissions = PermissionsFlag.Doctor;

            // Act
            List<Staff> actualResults = adminController.GetOnDutyStaff(new DateTime(2013, 11, 20));

            // Assert
            CollectionAssert.AreEqual(expectedResults, actualResults);
        }
        public void TestFindPatientOnSearch()
        {
            // Arrange
            AdminController adminController = new AdminController();
            List<Patient> expectedPatient = new List<Patient>();
            expectedPatient.Add(new Patient());
            expectedPatient[0].PatientID = 1;
            expectedPatient[0].FirstName = "test";
            expectedPatient[0].LastName = "test";
            expectedPatient[0].DateOfBirth = new DateTime(1991, 2, 5);
            expectedPatient[0].Gender = PersonGender.Male;
            expectedPatient[0].TelephoneNumber = "00000000000";
            expectedPatient[0].EmailAddress = "test";
            expectedPatient[0].AddressLine1 = "test";
            expectedPatient[0].AddressLine2 = "test";
            expectedPatient[0].City = "test";
            expectedPatient[0].County = "test";
            expectedPatient[0].PostCode = "test";
            expectedPatient[0].MaritalStatus = "married";

            // Act
            List<Patient> actualPatient = adminController.GetPatientDetails("1", "test", "test", "05/02/1991", "test");

            // Assert
            CollectionAssert.AreEqual(expectedPatient, actualPatient);
        }
        public void TestFindPatientOnID()
        {
            // Arrange
            AdminController adminController = new AdminController();
            Patient expectedPatient = new Patient();
            expectedPatient.PatientID = 1;
            expectedPatient.FirstName = "test";
            expectedPatient.LastName = "test";
            expectedPatient.DateOfBirth = new DateTime(1991, 2, 5);
            expectedPatient.Gender = PersonGender.Male;
            expectedPatient.TelephoneNumber = "00000000000";
            expectedPatient.EmailAddress = "test";
            expectedPatient.AddressLine1 = "test";
            expectedPatient.AddressLine2 = "test";
            expectedPatient.City = "test";
            expectedPatient.County = "test";
            expectedPatient.PostCode = "test";
            expectedPatient.MaritalStatus = "married";

            // Act
            Patient actualPatient = adminController.GetPatientDetails(1);

            // Assert
            Assert.AreEqual(expectedPatient, actualPatient);
        }
        public void TestFindStaffOnID()
        {
            // Arrange
            AdminController adminController = new AdminController();

            Staff expectedStaff = new Staff();
            expectedStaff.StaffID = 1;
            expectedStaff.FirstName = "test";
            expectedStaff.LastName = "test";
            expectedStaff.DateOfBirth = new DateTime(2013, 2, 5);
            expectedStaff.Gender = PersonGender.Male;
            expectedStaff.TelephoneNumber = "00000000000";
            expectedStaff.EmailAddress = "test";
            expectedStaff.AddressLine1 = "test";
            expectedStaff.AddressLine2 = "test";
            expectedStaff.City = "test";
            expectedStaff.County = "test";
            expectedStaff.PostCode = "test";
            expectedStaff.MaritalStatus = "single";
            expectedStaff.Permissions = PermissionsFlag.Doctor;

            // Act
            Staff actualStaff = adminController.GetStaffDetails(1);

            // Assert
            Assert.AreEqual(expectedStaff, actualStaff);
        }
        public void TestExtendSuccess()
        {
            // Arrange
            AdminController ac = new AdminController();
            bool expected = true;

            Prescription prescription = new Prescription();
            prescription.PrescriptionID = 2;
            prescription.PatientID = 1;
            prescription.StaffID = 1;
            prescription.StartDate = new DateTime(2013, 01, 01);
            prescription.EndDate = new DateTime(2013, 02, 01);
            prescription.Extended = false;
            prescription.Medicines = new List<Medicine>();
            prescription.Medicines.Add(new Medicine());
            prescription.Medicines[0].MedicineID = 2;
            prescription.Medicines[0].MedicineName = "Thyroxine";
            prescription.Medicines[0].Dosage = "50mg";
            prescription.Medicines[0].Extendable = true;

            // Act
            bool actual = ac.ExtendPrescription(prescription);

            // Assert
            Assert.AreEqual(expected, actual);
        }
        public void TestAddPatientDoesntExist()
        {
            // Arrange
            AdminController ac = new AdminController();
            bool expected = true;

            // Act
            bool actual = ac.AddPatient("test", "test", "test", "test", "test", "test", "test", new DateTime(1991, 02, 05), "test", 0, "single", "00000000000");

            // Assert
            Assert.AreEqual(expected, actual);
        }
        public FormFindPatient()
        {
            InitializeComponent();

            _patients = new List<Patient>();
            _adminController = new AdminController();

            // Add the event handler for the find patient control
            patientSearch.PatientSelected += SelectPatient;
            // Pass the controller through
            patientSearch.AdminController = _adminController;
        }
        public FormFindStaff()
        {
            InitializeComponent();

            _staff = new List<Staff>();

            _adminController = new AdminController();
            _managementController = new ManagementController();

            // Add event handler to the staff search
            staffSearch.StaffSelected += SelectStaff;
            staffSearch.AdminController = _adminController;
        }
        public FormAddAbsence(Staff staff)
        {
            InitializeComponent();

            _adminController = new AdminController();
            _staff = staff;

            // Create the management controls if the current user can use them
            if (UserSession.Instance().CurrentUser.Permissions == PermissionsFlag.Management)
            {
                _managementController = new ManagementController();
            }

            RefreshForm();
        }
        public void TestAddAppointmentExists()
        {
            // Arrange
            AdminController adminController = new AdminController();
            bool expected = false;

            Staff staff = new Staff();
            staff.StaffID = 1;

            Patient patient = new Patient();
            patient.PatientID = 1;

            // Act
            bool actual = adminController.AddAppointment(new DateTime(2000, 1, 1, 9, 0, 0), new DateTime(2000, 1, 1, 9, 15, 0), staff, patient);

            // Assert
            Assert.AreEqual(expected, actual);
        }
        public void TestCancelAppointmentSuccess()
        {
            // Arrange
            AdminController ac = new AdminController();
            bool expected = true;

            Appointment app = new Appointment();
            app.AppointmentID = 1;
            app.PatientID = 1;
            app.StaffID = 1;
            app.StartDate = new DateTime(2000, 1, 1, 9, 0, 0);
            app.EndDate = new DateTime(2000, 1, 1, 9, 15, 0);

            // Act
            bool actual = ac.CancelAppointment(app);

            // Assert
            Assert.AreEqual(expected, actual);
        }
        public FormAddAppointment(DateTime date, TimeSpan startTime, TimeSpan endTime, Staff staff)
        {
            InitializeComponent();

            _adminController = new AdminController();

            // Set the appointment details
            _staff = staff;
            _startDate = date.Add(startTime);
            _endDate = date.Add(endTime);

            // Add the event handle for the find patient control
            patientSearch.PatientSelected += SelectPatient;

            // Pass the admin controller to the patient search
            patientSearch.AdminController = _adminController;

            RefreshForm();
        }
        public FormAddPatient()
        {
            InitializeComponent();

            // Escape closes the dialog window
            this.CancelButton = cancelBtn;

            adminController = new AdminController();

            // Validate all of the user entered values
            textBoxes = new TextBox[] { firstNameTxt, lastNameTxt, address1Txt, cityTxt, countyTxt, postCodeTxt, dateOfBirthTxt, emailTxt, telNoTxt };

            // Add event handlers for each of the textboxes
            foreach (TextBox t in textBoxes)
            {
                t.TextChanged += TxtChanged;
            }

            // Populate the combo box based on the gender enum
            genderCmb.DataSource = Enum.GetValues(typeof(PersonGender));
        }
        public FormAppointmentDetails(Appointment appointment)
        {
            InitializeComponent();
            _adminController = new AdminController();
            _appointment = appointment;

            // Start times of the day
            TimeSpan startTime = new TimeSpan(9, 0, 0);
            TimeSpan endTime = new TimeSpan(9, 15, 0);

            // Populate form fields
            PopulateFields();
            PopulateComboBox(startTimeCmb,  startTime, _appointment.StartDate);
            PopulateComboBox(endTimeCmb, endTime, _appointment.EndDate);

            // Allow editing if the appointment is in the future
            if (_appointment.StartDate > DateTime.Now)
            {
                //modifyAppointmentBtn.Enabled = true;
                cancelAppointmentBtn.Enabled = true;
            }
        }
        public void TestAddAppointmentDoesntExist()
        {
            // Arrange
            AdminController adminController = new AdminController();

            // Create basic a staff
            Staff staff = new Staff();
            staff.StaffID = 1;

            // Create a basic patient
            Patient patient = new Patient();
            patient.PatientID = 1;

            // Expected result
            bool expected = true;

            // Need to clear the appointments table

            // Act
            bool actual = adminController.AddAppointment(new DateTime(2002, 1, 1, 9, 0, 0), new DateTime(2002, 1, 1, 9, 15, 0), staff, patient);

            // Assert
            Assert.AreEqual(expected, actual);
        }
        public void TestGetPatientAppointments()
        {
            // Arrange
            AdminController adminController = new AdminController();
            Patient patient = new Patient();
            patient.Appointments = new List<Appointment>();
            patient.Appointments.Add(new Appointment());
            patient.Appointments[0].AppointmentID = 1;
            patient.Appointments[0].PatientID = 1;
            patient.Appointments[0].StaffID = 1;
            patient.Appointments[0].StartDate = new DateTime(2000, 01, 01, 9, 0, 0);
            patient.Appointments[0].EndDate = new DateTime(2000, 01, 01, 9, 15, 0);

            Patient expectedPatient = new Patient();

            // Act
            expectedPatient.Appointments = adminController.GetPatientAppointments(1);

            // Assert
            CollectionAssert.AreEqual(patient.Appointments, expectedPatient.Appointments);
        }
        public void TestGetStaffAppointmentsSuccess()
        {
            // Arrange
            AdminController adminController = new AdminController();
            Staff staff = new Staff();
            staff.Appointments = new List<Appointment>();
            staff.Appointments.Add(new Appointment());
            staff.Appointments[0].AppointmentID = 1;
            staff.Appointments[0].PatientID = 1;
            staff.Appointments[0].StaffID = 1;
            staff.Appointments[0].StartDate = new DateTime(2000, 01, 01, 9, 0, 0);
            staff.Appointments[0].EndDate = new DateTime(2000, 01, 01, 9, 15, 0);

            Staff actualStaff = new Staff();

            // Act
            actualStaff.Appointments = adminController.GetStaffAppointments(1);

            // Assert
            CollectionAssert.AreEqual(staff.Appointments, actualStaff.Appointments);
        }