public void GetPatientDiseaseTest_ValidPatientDiseaseId(int patientDiseaseId) { // Arrange _mockData.Setup(q => q.PatientDiseases.Get(patientDiseaseId)).Returns(_patientDiseasesList[patientDiseaseId - 1]); // Act var actual = new PatientDiseaseService(_mockData.Object).GetPatientDisease(patientDiseaseId); // Assert Assert.AreEqual(_patientDiseasesList[patientDiseaseId - 1], actual); }
public void GetPatientDiseaseTest_InValidPatientDiseaseId(int patientDiseaseId) { // Arrange _mockData.Setup(q => q.PatientDiseases.Get(patientDiseaseId)).Returns(default(PatientDisease)); // Act var actual = new PatientDiseaseService(_mockData.Object).GetPatientDisease(patientDiseaseId); // Assert Assert.AreEqual(null, actual); }
public void GetDiseaseByPatientTest_ValidPatientId(int patientId) { // Arrange _mockData.Setup(q => q.PatientDiseases.GetAll()).Returns(_patientDiseasesList.AsQueryable); _mockData.Setup(q => q.Diseases.GetAll()).Returns(_diseasesList.AsQueryable); // Act var actual = new PatientDiseaseService(_mockData.Object).GetDiseaseByPatient(patientId).ToList(); // Assert Assert.AreEqual(2, actual.Count()); Assert.AreEqual(_diseasesList[1], actual[0]); Assert.AreEqual(_diseasesList[2], actual[1]); }
public void GetPatientDiseasesInfosTest(int patientId) { // Arrange _mockData.Setup(q => q.PatientDiseases.GetAll()).Returns(_patientDiseasesList.AsQueryable); _mockData.Setup(q => q.Diseases.GetAll()).Returns(_diseasesList.AsQueryable); _mockData.Setup(q => q.Categories.GetAll()).Returns(_categoriesList.AsQueryable); _mockData.Setup(q => q.Patients.GetAll()).Returns(_patientsList.AsQueryable); _mockData.Setup(q => q.Users.GetAll()).Returns(_usersList.AsQueryable); IEnumerable <PatientDiseaseInfo> expected = new List <PatientDiseaseInfo>() { new PatientDiseaseInfo() { Id = 2, CategoryName = "Test Category 1", IsCurrent = false, Name = "Test Disease Name 2", Doctor = "Ustinov", StartDate = new DateTime(2018, 11, 10) }, new PatientDiseaseInfo() { Id = 3, CategoryName = "Test Category 2", IsCurrent = true, Name = "Test Disease Name 3", Doctor = "Ustinov", StartDate = new DateTime(2018, 11, 2) } }; // Act var actual = new PatientDiseaseService(_mockData.Object).GetPatientDiseasesInfos(patientId); // Assert Assert.AreEqual(expected.Count(), actual.Count()); Assert.AreEqual(expected.ElementAt(0).Id, actual.ElementAt(0).Id); Assert.AreEqual(expected.ElementAt(1).Id, actual.ElementAt(1).Id); Assert.AreEqual(expected.ElementAt(0).CategoryName, actual.ElementAt(0).CategoryName); Assert.AreEqual(expected.ElementAt(1).CategoryName, actual.ElementAt(1).CategoryName); Assert.AreEqual(expected.ElementAt(0).IsCurrent, actual.ElementAt(0).IsCurrent); Assert.AreEqual(expected.ElementAt(1).IsCurrent, actual.ElementAt(1).IsCurrent); Assert.AreEqual(expected.ElementAt(0).Name, actual.ElementAt(0).Name); Assert.AreEqual(expected.ElementAt(1).Name, actual.ElementAt(1).Name); Assert.AreEqual(expected.ElementAt(0).Doctor, actual.ElementAt(0).Doctor); Assert.AreEqual(expected.ElementAt(1).Doctor, actual.ElementAt(1).Doctor); }