예제 #1
0
        public async Task DeletePatient_SuccessResult()
        {
            PatientLogic patientData = new PatientLogic(this.patRepo.Object);

            // Create model
            PatientViewModel model = new PatientViewModel()
            {
                PatientId   = 1,
                FirstName   = "Andrew",
                LastName    = "Moshko",
                MiddleName  = "Victor",
                Age         = "18",
                Weight      = "83",
                Height      = "195",
                Email       = "*****@*****.**",
                PhoneNumber = "+380995135682",
                HomeNumber  = "-",
                Sex         = "man",
                Condition   = "test Patient"
            };

            // Create object Doctor
            Patient patient = model.ToEntity();

            this.ultraRepository.Setup(x => x.AddPatientAsync(patient))
            .ReturnsAsync(patient).Verifiable();

            this.ultraRepository.Setup(x => x.DeletePatientAsync(patient.PatientId))
            .ReturnsAsync(true).Verifiable();

            // Run Code
            var result = await patientData.DeletePatientAsync(model.PatientId); // AddAsync(mockModel.Object);

            Assert.True(result);
        }
예제 #2
0
        public void ToEntity_PatientEqualsViewModel()
        {
            PatientViewModel testPatient = new PatientViewModel
            {
                PatientId   = 1,
                FirstName   = "Andrew",
                LastName    = "Moshko",
                MiddleName  = "Victor",
                Age         = "18",
                Weight      = "83",
                Height      = "195",
                Email       = "*****@*****.**",
                PhoneNumber = "+380995135682",
                HomeNumber  = "-",
                Sex         = "man",
                Condition   = "lazy student with diploma in front of his nose"
            };

            Patient patient = testPatient.ToEntity();

            Assert.Equal(testPatient.PatientId, patient.PatientId);
            Assert.Equal(testPatient.FirstName, patient.FirstName);
            Assert.Equal(testPatient.LastName, patient.LastName);
            Assert.Equal(testPatient.MiddleName, patient.MiddleName);
            Assert.Equal(testPatient.Age, patient.Age);
            Assert.Equal(testPatient.Weight, patient.Weight);
            Assert.Equal(testPatient.Height, patient.Height);
            Assert.Equal(testPatient.PhoneNumber, patient.PhoneNumber);
            Assert.Equal(testPatient.HomeNumber, patient.HomeNumber);
            Assert.Equal(testPatient.Sex, patient.Sex);
            Assert.Equal(testPatient.Condition, patient.Condition);
        }
예제 #3
0
        // public async Task<PatientViewModel> AddPatientAsync(PatientViewModel patientViewModel)
        // {
        //    try
        //    {
        //        Patient patient = await this.UltraRepository.AddPatientAsync(patientViewModel.ToEntity());

        // patientViewModel.ToModel(patient);

        // return patientViewModel;
        //    }
        //    catch (Exception ex)
        //    {
        //        throw ex;
        //    }
        // }

        public async Task <PatientViewModel> AddPatientAsync(PatientViewModel patientViewModel)
        {
            try
            {
                Patient patient = await this.repository.AddPatientAsync(patientViewModel.ToEntity());

                patientViewModel.ToModel(patient);

                return(patientViewModel);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
예제 #4
0
        public async Task AddPatient_SuccessResult()
        {
            PatientLogic patientData = new PatientLogic(this.patRepo.Object);

            // Create model
            PatientViewModel model = new PatientViewModel()
            {
                PatientId   = 1,
                FirstName   = "Andrew",
                LastName    = "Moshko",
                MiddleName  = "Victor",
                Age         = "18",
                Weight      = "83",
                Height      = "195",
                Email       = "*****@*****.**",
                PhoneNumber = "+380995135682",
                HomeNumber  = "-",
                Sex         = "man",
                Condition   = "test Patient"
            };

            // Create object Doctor
            Patient patient = model.ToEntity();

            this.ultraRepository.Setup(x => x.AddPatientAsync(patient))
            .ReturnsAsync(patient).Verifiable();

            // Run Code
            var result = await patientData.AddPatientAsync(model);

            // validate true result
            Assert.Equal(result.PatientId, model.PatientId);
            Assert.Equal(result.FirstName, model.FirstName);
            Assert.Equal(result.LastName, model.LastName);
            Assert.Equal(result.MiddleName, model.MiddleName);
            Assert.Equal(result.Age, model.Age);
            Assert.Equal(result.Weight, model.Weight);
            Assert.Equal(result.Height, model.Height);
            Assert.Equal(result.Email, model.Email);
            Assert.Equal(result.PhoneNumber, model.PhoneNumber);
            Assert.Equal(result.HomeNumber, model.HomeNumber);
            Assert.Equal(result.Sex, model.Sex);
            Assert.Equal(result.Condition, model.Condition);
        }
예제 #5
0
        public async Task <PatientViewModel> UpdatePatientAsync(PatientViewModel patientViewModel)
        {
            try
            {
                Patient patient = new Patient();
                Debug.WriteLine($"1\n");
                patient = await this.repository.UpdatePatientAsync(patientViewModel.ToEntity());

                Debug.WriteLine($"{patient.PatientId}\n{patient.Email}\n{patient.FirstName}\n{patient.Condition}\n ");

                patientViewModel.ToModel(patient);

                return(patientViewModel);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }