Ejemplo n.º 1
0
        public void simpleFindersShouldWork()
        {
            // Arrange
            ApplicationDbContext dbContext     = Shared.GetDatabaseContext();
            DoctorService        doctorService = new DoctorService(dbContext);
            var doctors = new[]
            {
                new Doctor {
                    Id = 1, Specialization = "a"
                },
                new Doctor {
                    Id = 2, Specialization = "b"
                },
                new Doctor {
                    Id = 3, Specialization = "c"
                },
            };

            dbContext.Doctors.AddRange(doctors);
            dbContext.SaveChanges();

            // Act
            Doctor foundDoctor = doctorService.FindDoctor(2);

            Doctor[] foundDoctors = doctorService.FindAllDoctors();

            // Assert
            Assert.Equal(2, foundDoctor.Id);
            Assert.Equal("b", foundDoctor.Specialization);
            Assert.Collection(foundDoctors,
                              doc => Assert.Equal(1, doc.Id),
                              doc => Assert.Equal(2, doc.Id),
                              doc => Assert.Equal(3, doc.Id)
                              );
        }
Ejemplo n.º 2
0
 public IActionResult List([FromQuery(Name = "patient")] int?patientId)
 {
     ViewBag.doctorViews = doctorService
                           .FindAllDoctors()
                           .Select(doctor => new DoctorViewModel(doctor, doctorService))
                           .ToArray();
     ViewBag.patientId = patientId;
     return(View());
 }
Ejemplo n.º 3
0
 public ActionResult <IEnumerable <Doctor> > List()
 {
     return(Ok(doctorService.FindAllDoctors()));
 }