Ejemplo n.º 1
0
        public void GivenCalendarWhenCreatingNewAppointmentThenDatesAreToday()
        {
            IActionResult result = _controller.Create();

            Assert.That(result, Is.TypeOf <PartialViewResult>());
            var viewResult = (PartialViewResult)result;

            Assert.That(viewResult.Model, Is.TypeOf <NewAppointmentViewModel>());
            var model = (NewAppointmentViewModel)viewResult.Model;

            Assert.That(model.StartDate, Is.EqualTo(DateTime.Today));
            Assert.That(model.EndDate, Is.EqualTo(DateTime.Today));
        }
Ejemplo n.º 2
0
        public async void CreateAppointment_WhenCalledWithValidAppointment_ReturnsCreated()
        {
            // Arrange
            var apptItem = new AppointmentEntity()
            {
                PatientID           = 200,
                AppointmentDateTime = DateTime.Now.AddDays(1)
            };
            var apptDtoItem = FakeBookings.GetFakeAppointmentDto();
            var mapper      = TestHelpers.Helpers.GetAppointmentMapperForTest();

            _repo.CreateBookingAsync(apptItem).ReturnsForAnyArgs(true);

            var mycontroller       = new AppointmentsController(_repo, _notify, mapper, _logger);
            var expectedCodeResult = new StatusCodeResult(201);


            // Act
            var sut = await mycontroller.Create(apptDtoItem);

            var result = sut as StatusCodeResult;

            // Assert
            Assert.NotNull(result);
            Assert.Equal(expectedCodeResult.StatusCode, result.StatusCode);
        }
Ejemplo n.º 3
0
        public async void CreateAppointment_WhenCalledWithInvalidAppointment_ReturnsBadRequest()
        {
            // Arrange
            var apptItem = new AppointmentEntity()
            {
                PatientID           = 200,
                AppointmentDateTime = DateTime.Now.AddDays(20) /* Invalid data: Rule is appointment can be booked upto two weeks ahead only */
            };
            var apptDtoItem = FakeBookings.GetFakeAppointmentDto();
            var mapper      = TestHelpers.Helpers.GetAppointmentMapperForTest();

            _repo.CreateBookingAsync(apptItem).ReturnsForAnyArgs(false);

            var mycontroller       = new AppointmentsController(_repo, _notify, mapper, _logger);
            var expectedCodeResult = new StatusCodeResult(400);


            // Act
            var sut = await mycontroller.Create(apptDtoItem);

            var result = sut as BadRequestObjectResult;

            // Assert
            Assert.NotNull(result);
            Assert.Equal(expectedCodeResult.StatusCode, result.StatusCode);
        }
        public void Create()
        {
            // Arrange
            AppointmentsController controller = new AppointmentsController();

            // Act
            ViewResult result = controller.Create() as ViewResult;

            // Assert
            Assert.IsNotNull(result);
        }
Ejemplo n.º 5
0
        public void CreateAppointmentTest()
        {
            string fakeDress = "fake";
            string fakecolor = "fake";

            AppointmentsController controller = SetMockAndGetAppointmentController();
            var mockAppContext = new Mock <ApplicationDbContext>();


            var Appointment = FakeAppointmentList.First();
            var result      = controller.Create(Appointment, fakeDress, fakecolor);

            Assert.IsType <RedirectToActionResult>(result);
        }
        public void Create_Appointment_RedirectToActionResult()
        {
            var mockContext = new Mock <OnlineClinicContext>();
            var controller  = new AppointmentsController(mockContext.Object);
            var appointment = new Appointment()
            {
                Id      = 1,
                Doctor  = new Doctor(),
                Patient = new Patient(),
                Slot    = new Slot()
            };

            var task = controller.Create(appointment);

            //Assert.IsType<RedirectToActionResult>(task.Result);
        }
Ejemplo n.º 7
0
        public void CreateAppointment()
        {
            var controller = new AppointmentsController();

            var start   = new DateTime(2016, 1, 15, 13, 0, 0);
            var end     = start.AddHours(2);
            var request = new CreateAppointmentRequest
            {
                Body       = "Appointment Created from Unit Test",
                Location   = "Cconference Room",
                Subject    = "Appointment Unit Test",
                Start      = start.ToString(),
                End        = end.ToString(),
                Recipients = new List <string> {
                    "*****@*****.**"
                }
            };

            var result = controller.Create(request) as OkNegotiatedContentResult <CreateAppointmentResponse>;

            Assert.IsNotNull(result.Content.AppointId);
            Assert.IsNotNull(result.Content.Message);
        }
Ejemplo n.º 8
0
        public void TestCreate_Valid_Post()
        {
            var httpContext = Tools.MockHttpContext(false);
            var dbContext   = Tools.MockTestDatabaseContext();
            var config      = Tools.MockTestConfig();
            var service     = Tools.MockEmailService();

            var controller = new AppointmentsController(dbContext, config, service)
            {
                ControllerContext = new ControllerContext()
                {
                    //Override http context, to return the proper user
                    HttpContext = httpContext
                }
            };

            Appointment newAppointment = new Appointment()
            {
                AppointmentDateTime = DateTime.Now,
                Confirmation        = false,
                DateMarried         = DateTime.Now,
                ID    = 9,
                Mail  = "*****@*****.**",
                Name  = "Test",
                Phone = "00000000000"
            };

            //Execute the method with the ID of the first appointment
            var result = controller.Create(newAppointment, "dressname", "dresscolor");

            //Check the result, we should have gotten a RedirectToAction
            Assert.IsType <RedirectToActionResult>(result);

            //Check if the item was added to the database context
            Assert.Contains(newAppointment, dbContext.Appointment);
        }