コード例 #1
0
        public void GetAppointmentsByPatientId_Count_AppointmentsResponse_Test()
        {
            //Arrage
            IDbContext  dbContext      = new MedicalAppointmentContext();
            IRepository repository     = new AppointmentRepository(dbContext);
            var         sut            = new AppointmentsController(repository);
            var         expectedResult = 1;

            //Act
            var result = sut.GetByPatientId(1) as OkNegotiatedContentResult <IEnumerable <IAppointment> >;
            var appointmentListResult = result.Content as List <Appointment>;

            //Assert
            Assert.AreEqual(expectedResult, appointmentListResult.Count);
        }
コード例 #2
0
        public void GetAppointmentByPatientId_NotNullResponse_Test()
        {
            //Arrage
            IDbContext  dbContext  = new MedicalAppointmentContext();
            IRepository repository = new AppointmentRepository(dbContext);
            var         sut        = new AppointmentsController(repository);

            //Act
            var result = sut.GetByPatientId(1) as OkNegotiatedContentResult <IEnumerable <IAppointment> >;
            var appointmentListResult = result.Content as List <Appointment>;

            //Assert
            Assert.IsNotNull(result);
            Assert.IsNotNull(appointmentListResult);
        }
コード例 #3
0
        public void GetAppointmentsByPatientId_ValidDataResponse_Test()
        {
            //Arrage
            IDbContext  dbContext      = new MedicalAppointmentContext();
            IRepository repository     = new AppointmentRepository(dbContext);
            var         sut            = new AppointmentsController(repository);
            var         expectedResult = new Appointment()
            {
                Id = 1, PatientId = 1, AppointmentTypeId = 1, Date = new DateTime(2019, 8, 10, 12, 30, 00), IsActive = true
            };

            //Act
            var result = sut.GetByPatientId(1) as OkNegotiatedContentResult <IEnumerable <IAppointment> >;
            var appointmentListResult = result.Content as List <Appointment>;
            var appointmentResult     = appointmentListResult.First();

            //Assert
            Assert.AreEqual(expectedResult.Id, appointmentResult.Id);
            Assert.AreEqual(expectedResult.PatientId, appointmentResult.PatientId);
            Assert.AreEqual(expectedResult.AppointmentTypeId, appointmentResult.AppointmentTypeId);
            Assert.AreEqual(expectedResult.Date, appointmentResult.Date);
            Assert.AreEqual(expectedResult.IsActive, appointmentResult.IsActive);
        }