public void ShowVisitsTestVisitsCount() { TestDBConnector fakeDBModel = new TestDBConnector(); Logic testLogic = new Logic(fakeDBModel); using (ExampleData data = new ExampleData(0)) { Doctor dr = data.ExampleDoctor(); Patient p = data.ExamplePatient(); testLogic.AddDoctor(dr); testLogic.CreatePatient(p); DateTime dt = data.ExampleTime(); dt = dt.AddMinutes(60 - dt.Minute); testLogic.AddVisit(dt.AddMinutes(45), p, dr); dr.LicenseNumber = "555555"; testLogic.AddDoctor(dr); dr.LicenseNumber = "123456"; testLogic.AddDoctor(dr); IEnumerable <Visit> list = testLogic.ShowVisits(dt.Date, dt.Hour.ToString(), 24.ToString(), dr.Surname, "", dr.Specialization, false, 0, 50); IEnumerable <Visit> withPatients = list.Where(v => v.Patient != null); Assert.AreEqual(1, withPatients.Count()); } }
public void ShowVisitsTestCount() { TestDBConnector fakeDBModel = new TestDBConnector(); Logic testLogic = new Logic(fakeDBModel); using (ExampleData data = new ExampleData(0)) { Doctor dr = data.ExampleDoctor(); Patient p = data.ExamplePatient(); testLogic.AddDoctor(dr); testLogic.CreatePatient(p); DateTime dt = data.ExampleTime(); dt = dt.AddMinutes(60 - dt.Minute); for (DateTime _dt = dt; _dt < dt.AddHours(3); _dt = _dt.AddMinutes(15)) { testLogic.AddVisit(_dt, p, dr); } dr.LicenseNumber = "55555"; testLogic.AddDoctor(dr); for (DateTime _dt = dt; _dt < dt.AddHours(4); _dt = _dt.AddMinutes(15)) { testLogic.AddVisit(_dt, p, dr); } IEnumerable <Visit> list = testLogic.ShowVisits(dt.Date, dt.Hour.ToString(), 24.ToString(), dr.Surname, "", dr.Specialization, true, 0, 50); Assert.AreEqual(50, list.Count()); } }
public void DeleteVisitTest2() { TestDBConnector fakeDBModel = new TestDBConnector(); Logic testLogic = new Logic(fakeDBModel); using (ExampleData data = new ExampleData(0)) { Patient p = data.ExamplePatient(); Doctor dr = data.ExampleDoctor(); DateTime dt1 = data.ExampleTime(); DateTime dt2 = data.ExampleTime(); testLogic.AddDoctor(dr); testLogic.CreatePatient(p); testLogic.AddVisit(dt1, p, dr); testLogic.AddVisit(dt2, p, dr); testLogic.DeleteVisit(dt1, dr, p); Assert.AreEqual(1, fakeDBModel.__visits.Count); } }
public void ShowVisitsTestAnyVisit() { TestDBConnector fakeDBModel = new TestDBConnector(); Logic testLogic = new Logic(fakeDBModel); using (ExampleData data = new ExampleData(0)) { Doctor dr = data.ExampleDoctor(); testLogic.AddDoctor(dr); DateTime dt = data.ExampleTime(); IEnumerable <Visit> list = testLogic.ShowVisits(dt.Date, dt.Hour.ToString(), 24.ToString(), dr.Surname, "", dr.Specialization, true, 0, 1); Assert.AreNotEqual(null, list.First().Date); } }
public void ShowVisitsTestNull() { TestDBConnector fakeDBModel = new TestDBConnector(); Logic testLogic = new Logic(fakeDBModel); using (ExampleData data = new ExampleData(0)) { ; Doctor dr = data.ExampleDoctor(); DateTime dt = data.ExampleTime(); var list = testLogic.ShowVisits(dt, 8.ToString(), 20.ToString(), dr.Name, "", dr.Specialization, true, 0, 0); Assert.AreEqual(null, list); } }
public void ShowPatientVisitsTest() { TestDBConnector fakeDBModel = new TestDBConnector(); Logic testLogic = new Logic(fakeDBModel); using (ExampleData data = new ExampleData(0)) { Patient p = data.ExamplePatient(); Doctor dr = data.ExampleDoctor(); DateTime dt = data.ExampleTime(); testLogic.CreatePatient(p); testLogic.AddDoctor(dr); testLogic.AddVisit(dt, p, dr); List <Visit> list = (List <Visit>)testLogic.ShowPatientVisits(p); Assert.AreEqual(p.PESELNumber, list[0].Patient.PESELNumber); Assert.AreEqual(dr.LicenseNumber, list[0].Doctor.LicenseNumber); Assert.AreEqual(dt, list[0].DT); } }
public void ShowVisitsTestDoctorsCount() { TestDBConnector fakeDBModel = new TestDBConnector(); Logic testLogic = new Logic(fakeDBModel); using (ExampleData data = new ExampleData(0)) { Doctor dr = data.ExampleDoctor(); Patient p = data.ExamplePatient(); testLogic.AddDoctor(dr); testLogic.CreatePatient(p); DateTime dt = data.ExampleTime(); dt = dt.AddMinutes(60 - dt.Minute); dr.LicenseNumber = "555555"; testLogic.AddDoctor(dr); dr.LicenseNumber = "123456"; testLogic.AddDoctor(dr); IEnumerable <Visit> list = testLogic.ShowVisits(dt.Date, dt.Hour.ToString(), 24.ToString(), dr.Surname, "", dr.Specialization, true, 0, 50); IEnumerable <Visit> drList = list.GroupBy(v => v.Doctor.LicenseNumber).Select(group => group.First()); Assert.AreEqual(3, drList.Count()); } }