public List<User> GetDemoUsers(Clinic clinic) { var users = new List<User>() { new User() { Id = entityIdIncrement++, FirstName = "Mark", LastName = "Oliver", Login = "******", Role = ClinicalStudyRoles.Supervisor, Photo = GetBytesFromImage(SupervisorPhoto), CanVisitWebSite = true, Patients = new List<Patient>(), Clinic = clinic }, new User() { Id = entityIdIncrement++, FirstName = "Devid", LastName = "Mitchell", Login = "******", Role = ClinicalStudyRoles.Doctor, Photo = GetBytesFromImage(DoctorPhoto), CanVisitWebSite = true, Patients = new List<Patient>(), Clinic = clinic } }; clinic.Doctors.AddRange(users); return users; }
public void GetOpenQueries() { //Arrange var dataStorage = new Mock<IDataStorage>(); var clinic = new Clinic {Caption = "Clinic1"}; var doctor1 = new User {FirstName = "DoctorFirst1", LastName = "DoctorLast1", Clinic = clinic}; var doctor2 = new User {FirstName = "DoctorFirst2", LastName = "DoctorLast2", Clinic = clinic}; var patient1 = new Patient {PatientNumber = 11, Doctor = doctor1}; var patient2 = new Patient {PatientNumber = 12, Doctor = doctor2}; var visit1 = new Visit {Caption = "Visit1", Patient = patient1}; var visit2 = new Visit {Caption = "Visit2", Patient = patient2}; var form1 = new Form {FormType = FormType.Happiness, Visit = visit1}; var form2 = new Form {FormType = FormType.Demographics, Visit = visit2}; var question1 = new Question {Form = form1}; var question2 = new Question {Form = form2}; var query1 = new Query {Id = 1, QueryText = "Text1", Question = question1}; var query2 = new Query {Id = 2, QueryText = "Text2", AnswerText = "Answer1", Question = question2}; var repository = new QueryRepository(dataStorage.Object); dataStorage.Setup(ds => ds.GetData<Query>()).Returns(new List<Query> {query1, query2}); //Act var result = repository.GetOpenQueries(); //Assert Assert.That(result, Is.Not.Null); Assert.That(result.Count(), Is.EqualTo(1)); var query = result.ToList()[0]; Assert.That(query.FormType, Is.EqualTo(FormType.Happiness)); Assert.That(query.ClinicName, Is.EqualTo("Clinic1")); Assert.That(query.DoctorName, Is.EqualTo("DoctorLast1")); Assert.That(query.QuestionText, Is.EqualTo("Text1")); Assert.That(query.PatientNumber, Is.EqualTo(11)); Assert.That(query.VisitName, Is.EqualTo("Visit1")); }
private User GetClinicSupervisor(Clinic clinic) { return clinic.Doctors.FirstOrDefault(u => u.Role == ClinicalStudyRoles.Supervisor); }
public void Doctors_DetailGrid_Empty() { //Arrange var cRepository = new Mock<IClinicRepository>(); var controller = new AdministrationController(cRepository.Object); var clinicId = 222; var clinic = new Clinic {Id = clinicId, Caption = "Clinic111", Doctors = new List<User>()}; cRepository.Setup(r => r.GetByKey(clinicId)).Returns(clinic); //Act var result = controller.ClinicDoctors(clinicId); //Assert Assert.That(result, Is.Not.Null); Assert.That(result is PartialViewResult); var viewResultBase = result as ViewResultBase; Assert.That(viewResultBase.Model, Is.Not.Null); Assert.That(viewResultBase.ViewName, Is.EqualTo("_ClinicDoctorsGrid")); Assert.That(viewResultBase.Model is ClinicDetailsViewModel); var model = viewResultBase.Model as ClinicDetailsViewModel; Assert.That(model.Doctors.Count, Is.EqualTo(0)); Assert.That(model.ClinicId, Is.EqualTo(clinicId)); cRepository.Verify(r => r.GetByKey(clinicId), Times.Once()); }
public void Doctors_DetailGrid() { //Arrange var cRepository = new Mock<IClinicRepository>(); var controller = new AdministrationController(cRepository.Object); var clinicId = 111; var doctor1 = new User { Id = 10, FirstName = "First10", LastName = "Last10", Role = "Doctor", Patients = new List<Patient> {new Patient()}, Login = "******", Photo = new byte[]{1,2,3} }; var doctor2 = new User { Id = 20, FirstName = "First20", LastName = "Last20", Role = "Supervisor", Patients = new List<Patient> {new Patient(), new Patient()}, Login = "******", Photo = new byte[]{3,4,5} }; var clinic = new Clinic {Id = clinicId, Caption = "Clinic111", Doctors = new List<User> {doctor1, doctor2}}; cRepository.Setup(r => r.GetByKey(clinicId)).Returns(clinic); //Act var result = controller.ClinicDoctors(clinicId); //Assert Assert.That(result, Is.Not.Null); Assert.That(result is PartialViewResult); var viewResultBase = result as ViewResultBase; Assert.That(viewResultBase.Model, Is.Not.Null); Assert.That(viewResultBase.ViewName, Is.EqualTo("_ClinicDoctorsGrid")); Assert.That(viewResultBase.Model is ClinicDetailsViewModel); var model = viewResultBase.Model as ClinicDetailsViewModel; Assert.That(model.Doctors, Is.Not.Null); Assert.That(model.Doctors.Count, Is.EqualTo(2)); Assert.That(model.ClinicId, Is.EqualTo(111)); Assert.That(model.Doctors[0].ClinicId, Is.EqualTo(111)); Assert.That(model.Doctors[0].DoctorId, Is.EqualTo(10)); Assert.That(model.Doctors[0].FirstName, Is.EqualTo("First10")); Assert.That(model.Doctors[0].LastName, Is.EqualTo("Last10")); Assert.That(model.Doctors[0].Role, Is.EqualTo("Doctor")); Assert.That(model.Doctors[0].PatientsCount, Is.EqualTo(1)); Assert.That(model.Doctors[0].Login, Is.EqualTo("login10")); Assert.That(model.Doctors[0].Photo, Is.EqualTo(new byte[] { 1, 2, 3 })); Assert.That(model.Doctors[1].ClinicId, Is.EqualTo(111)); Assert.That(model.Doctors[1].DoctorId, Is.EqualTo(20)); Assert.That(model.Doctors[1].FirstName, Is.EqualTo("First20")); Assert.That(model.Doctors[1].LastName, Is.EqualTo("Last20")); Assert.That(model.Doctors[1].Role, Is.EqualTo("Supervisor")); Assert.That(model.Doctors[1].PatientsCount, Is.EqualTo(2)); Assert.That(model.Doctors[1].Login, Is.EqualTo("login20")); Assert.That(model.Doctors[1].Photo, Is.EqualTo(new byte[] { 3, 4, 5 })); cRepository.Verify(r => r.GetByKey(clinicId), Times.Once()); }
private User CreateUserRecord(Clinic clinic, List<User>users, string role) { bool isMale = PeopleDataProvider.IsMale(); var user = new User() { Id = entityIdIncrement++, FirstName = PeopleDataProvider.GetRandomFirstName(isMale), LastName = PeopleDataProvider.GetRandomLastName(isMale), Photo = GetBytesFromImage(GetNextPhotoUrl(isMale)), CanVisitWebSite = false, Clinic = clinic, Patients = new List<Patient>(), Role = role }; CreateUserLoginName(user, users); users.Add(user); clinic.Doctors.Add(user); return user; }
private Patient CreatePatient(int clinicId, int doctorId, int patId) { var clinic = new Clinic {Id = clinicId, Caption = String.Format("Clinic{0}", clinicId)}; var doctor = new User { Id = doctorId, Clinic = clinic, Role = ClinicalStudyRoles.Doctor, FirstName = String.Format("First{0}", doctorId), LastName = String.Format("Last{0}", doctorId) }; var pat = new Patient {Id = patId, PatientNumber = 10 + patId, Doctor = doctor}; var demog = new Form { FormType = FormType.Demographics, Id = 201 + patId}; var hap1 = new Form {FormType = FormType.Happiness, Id = 202 + patId}; var hap2 = new Form { FormType = FormType.Happiness, Id = 203 + patId }; var visitB = new Visit {Id = 101 + patId, Caption = String.Format("Visit{0}", 101 + patId), VisitType = VisitType.Baseline, Forms = new List<Form>{demog}}; var visit1 = new Visit { Id = 102 + patId, Caption = String.Format("Visit{0}", 102 + patId), VisitType = VisitType.Day1, Forms = new List<Form>{hap1}}; var visit10 = new Visit { Id = 103 + patId, Caption = String.Format("Visit{0}", 103 + patId), VisitType = VisitType.Day10, Forms = new List<Form> { hap2 } }; pat.Visits = new List<Visit>{visitB, visit1, visit10}; return pat; }
public void CorrectModelMapping() { //Arrange var dataStorage = new Mock<IDataStorage>(); var repository = new QueryRepository(dataStorage.Object); var clinic = new Clinic {Caption = "Clinic"}; var doctor = new User {FirstName = "DoctorFirst", LastName = "DoctorLast", Clinic = clinic}; var patient = new Patient {Doctor = doctor}; var visit = new Visit {Caption = "Visit", Patient = patient}; var form1 = new Form {FormType = FormType.Happiness, Visit = visit}; var question1 = new Question {Caption = "QuestionCaption1", Form = form1}; var query1 = new Query {Id = 1, Question = question1}; var form2 = new Form {FormType = FormType.Inventory, Visit = visit}; var question2 = new Question {Caption = "QuestionCaption2", Form = form2}; var query2 = new Query {Id = 2, Question = question2, AnswerText = "Answer"}; dataStorage.Setup(ds => ds.GetData<Query>()).Returns(new List<Query> {query1, query2}); //Act var result = repository.GetQueriesReportData(); //Assert Assert.That(result, Is.Not.Null); Assert.That(result.Count(), Is.EqualTo(2)); var dto = result.ToList()[0]; Assert.That(dto.FormType, Is.EqualTo(FormType.Happiness)); Assert.That(dto.ClinicName, Is.EqualTo("Clinic")); Assert.That(dto.DoctorName, Is.EqualTo("DoctorFirst DoctorLast")); Assert.That(dto.QuestionName, Is.EqualTo("QuestionCaption1")); Assert.That(dto.IsOpen, Is.True); dto = result.ToList()[1]; Assert.That(dto.FormType, Is.EqualTo(FormType.Inventory)); Assert.That(dto.ClinicName, Is.EqualTo("Clinic")); Assert.That(dto.DoctorName, Is.EqualTo("DoctorFirst DoctorLast")); Assert.That(dto.QuestionName, Is.EqualTo("QuestionCaption2")); Assert.That(dto.IsOpen, Is.False); }
public void CorrectModelMapping() { //Arrange var dataStorage = new Mock<IDataStorage>(); var repository = new VisitRepository(dataStorage.Object); var clinic = new Clinic { Caption = "Clinic" }; var doctor1 = new User { FirstName = "DoctorFirst1", LastName = "DoctorLast1", Clinic = clinic }; var patient1 = new Patient { Doctor = doctor1 }; var visit1B = new Visit { Caption = "Visit1B", Patient = patient1, VisitType = VisitType.Baseline, Forms = new List<Form>{new Form { Id = 1, FormType = FormType.Demographics}}}; var visit1Ae1 = new Visit { Caption = "Visit1Ae1", Patient = patient1, VisitType = VisitType.AdverseEventVisit, Forms = new List<Form> { new Form { Id = 2, FormType = FormType.AdverseEvent } } }; var visit1Ae2 = new Visit { Caption = "Visit1Ae2", Patient = patient1, VisitType = VisitType.AdverseEventVisit, Forms = new List<Form> { new Form { Id = 3, FormType = FormType.AdverseEvent } } }; patient1.Visits = new List<Visit> {visit1B, visit1Ae1, visit1Ae2}; var doctor2 = new User { FirstName = "DoctorFirst2", LastName = "DoctorLast2", Clinic = clinic }; var patient2 = new Patient { Doctor = doctor2 }; var visit2B = new Visit { Caption = "Visit2B", Patient = patient2, VisitType = VisitType.Baseline, Forms = new List<Form> { new Form { Id = 13, FormType = FormType.Demographics } } }; var visit2Ae1 = new Visit { Caption = "Visit2Ae1", Patient = patient2, VisitType = VisitType.AdverseEventVisit, Forms = new List<Form> { new Form { Id = 23, FormType = FormType.AdverseEvent } } }; patient2.Visits = new List<Visit> { visit2B, visit2Ae1 }; dataStorage.Setup(ds => ds.GetData<Visit>()).Returns(new List<Visit> { visit1Ae1, visit1Ae2, visit1B, visit2B, visit2Ae1 }); //Act var result = repository.GetAeAnalyticsData(); //Assert Assert.That(result, Is.Not.Null); Assert.That(result.Count, Is.EqualTo(3)); var dto = result[0]; Assert.That(dto.ClinicName, Is.EqualTo("Clinic")); Assert.That(dto.DoctorName, Is.EqualTo("DoctorFirst1 DoctorLast1")); Assert.That(dto.DemographicFormId, Is.EqualTo(1)); Assert.That(dto.AeFormId, Is.EqualTo(2)); dto = result[1]; Assert.That(dto.ClinicName, Is.EqualTo("Clinic")); Assert.That(dto.DoctorName, Is.EqualTo("DoctorFirst1 DoctorLast1")); Assert.That(dto.DemographicFormId, Is.EqualTo(1)); Assert.That(dto.AeFormId, Is.EqualTo(3)); dto = result[2]; Assert.That(dto.ClinicName, Is.EqualTo("Clinic")); Assert.That(dto.DoctorName, Is.EqualTo("DoctorFirst2 DoctorLast2")); Assert.That(dto.DemographicFormId, Is.EqualTo(13)); Assert.That(dto.AeFormId, Is.EqualTo(23)); }