Пример #1
0
        public void Book_AvailabilityExists_ReturnViewPopulatedBookFormViewModel()
        {
            //Arrange
            var availability = new UserAvailability()
            {
                Id       = 1,
                DateTime = DateTime.Now
            };

            _mockAvailabilityService.Setup(m => m.GetAvailability(It.IsAny <int>())).Returns(availability);

            var types = new AppointmentType[] { new AppointmentType() };

            _mockAppointmentService.Setup(m => m.GetAppointmentTypes()).Returns(types);
            var times = new TimeSpan[] { new TimeSpan() };

            _mockAppointmentService.Setup(m => m.GetAppointmentStartTimes(availability)).Returns(times);
            _mockAppointmentService.Setup(m => m.GetAppointmentEndTimes(availability)).Returns(times);

            //Act
            var result = _controller.Book(1) as ViewResult;
            var model  = result.Model as BookFormViewModel;

            //Assert
            result.Should().NotBeNull();
            result.ViewName.Should().Be("BookForm");
            model.Availability.Id.Should().Be(availability.Id);
            model.Types.Should().HaveCount(1);
            model.StartTime.Should().Be(availability.GetStartTime());
            model.SelectableStartTimes.Should().BeEquivalentTo(times);
            model.SelectableEndTimes.Should().BeEquivalentTo(times);
        }
Пример #2
0
        public void OnNext()
        {
            Appointment appointment = (Appointment)_state[StateKeys.CurrentAppointment];

            if (isNew())
            {
                // If its a new appointment save the appointment first
                appointment = _appointmentController.Save(appointment);

                appointment.Slot    = new Slot();
                appointment.Slot.Id = (Guid)View.SlotId;

                _appointmentController.Book(appointment);
            }
            else // This is a book on pending appointment or a re-book attempt
            {
                bool isRebook = appointment.Slot != null;
                if (View.SlotId.HasValue)
                {
                    appointment.Slot    = new Slot();
                    appointment.Slot.Id = (Guid)View.SlotId;

                    if (isRebook)
                    {
                        _appointmentController.ReBook(appointment);
                    }
                    else
                    {
                        _appointmentController.Book(appointment);
                    }
                }
            }

            _state[StateKeys.CurrentAppointment] = appointment;
            _navigator.Navigate(NavigationKeys.Summary);
        }