public void Setup() { config = new MapperConfiguration(c => c.AddProfile(new MappingProfile())); mapper = config.CreateMapper(); unitOfWork = new UnitOfWork(Context); _itineraryHelper = new ItineraryHelper(unitOfWork, mapper); }
public void Build_WhenCalled_NullOrder_ShouldReturnNull() { var mockMapper = new Mock <IMapper>(); var mockUnitOfWork = new Mock <IUnitOfWork>(); _itineraryHelper = new ItineraryHelper(mockUnitOfWork.Object, mockMapper.Object); var result = _itineraryHelper.Build(null); result.Should().BeNull(); }
public void Build_Order_ShouldHaveOneServiceOnIntinerary() { Order order = new Order() { Id = "1", ServiceFlag = (int)ServiceCategory.AccompaniedHomeFinding }; order.Services.Add( new Service() { ServiceType = new ServiceType() { Name = "Unscheduled" }, ScheduledDate = null } ); order.Services.Add( new Service() { ServiceType = new ServiceType() { Name = "Completed" }, ScheduledDate = DateTime.Now, CompletedDate = DateTime.Now } ); order.Services.Add( new Service() { ServiceType = new ServiceType() { Name = "Scheduled" }, ScheduledDate = DateTime.Now.AddDays(1) } ); _itineraryHelper = new ItineraryHelper(unitOfWork, mapper); var result = _itineraryHelper.Build(order); result.Itinerary.Count().Should().Be(1); }
public ActionResult DashboardPartial(string id) { var userId = User.Identity.GetUserId(); var order = _unitOfWork.Orders.GetOrderFor(userId, id, User.GetUserRole()); if (order == null) { return(new HttpStatusCodeResult(HttpStatusCode.NotFound)); } var dashVM = _mapper.Map <Order, DashboardViewModel>(order); ItineraryHelper helper = new ItineraryHelper(_unitOfWork, _mapper); dashVM.Itinerary = helper.GetItinerary(order); return(PartialView("~/views/orders/partials/_Dashboard.cshtml", dashVM)); }
public void Build_WhenCalled_Should_NotReturn_Null() { var mockMapper = new Mock <IMapper>(); _mockServicesRepository = new Mock <IServicesRepository>(); _mockAppointmentsRepository = new Mock <IAppointmentsRepository>(); _mockHomeFindingPropertiesRepository = new Mock <IHomeFindingPropertyRepository>(); var mockUnitOfWork = new Mock <IUnitOfWork>(); _itineraryHelper = new ItineraryHelper(mockUnitOfWork.Object, mockMapper.Object); string orderId = "1"; var result = _itineraryHelper.Build(new Order()); result.Should().NotBeNull(); }
public void Build_WhenCalled_NoServices_Or_Appointments_Should_Return_Empty_Itinerary() { var mockMapper = new Mock <IMapper>(); _mockServicesRepository = new Mock <IServicesRepository>(); _mockAppointmentsRepository = new Mock <IAppointmentsRepository>(); _mockHomeFindingPropertiesRepository = new Mock <IHomeFindingPropertyRepository>(); var mockUnitOfWork = new Mock <IUnitOfWork>(); mockUnitOfWork.SetupGet(u => u.Services).Returns(_mockServicesRepository.Object); mockUnitOfWork.SetupGet(u => u.Appointments).Returns(_mockAppointmentsRepository.Object); mockUnitOfWork.SetupGet(u => u.HomeFindingProperties).Returns(_mockHomeFindingPropertiesRepository.Object); _itineraryHelper = new ItineraryHelper(mockUnitOfWork.Object, mockMapper.Object); string orderId = null; var result = _itineraryHelper.Build(orderId); result.Itinerary.GetEnumerator().MoveNext().Should().BeFalse(); }
public void Build_HomeFindingOrder_ShouldHaveViewingServiceAppointmentOnIntinerary() { Order order = new Order() { Id = "1", HomeFinding = new HomeFinding(), ServiceFlag = (int)ServiceCategory.AccompaniedHomeFinding }; order.HomeFinding.HomeFindingProperties.Add( new HomeFindingProperty() { ViewingDate = DateTime.Now.AddDays(1) } ); order.Appointments.Add( new Appointment() { Description = "Scheduled", ScheduledDate = DateTime.Now.AddDays(1) } ); order.Services.Add( new Service() { ServiceType = new ServiceType() { Name = "Scheduled" }, ScheduledDate = DateTime.Now.AddDays(1) } ); _itineraryHelper = new ItineraryHelper(unitOfWork, mapper); var result = _itineraryHelper.Build(order); result.Itinerary.Count().Should().Be(3); }
public void Build_Order_ShouldHaveOneAppointmentOnIntinerary() { Order order = new Order() { Id = "1", ServiceFlag = (int)ServiceCategory.AccompaniedHomeFinding }; order.Appointments.Add( new Appointment() { Description = "Deleted", ScheduledDate = DateTime.Now.AddDays(1), Deleted = true } ); order.Appointments.Add( new Appointment() { Description = "Past", ScheduledDate = DateTime.Now.AddDays(-1) } ); order.Appointments.Add( new Appointment() { Description = "Scheduled", ScheduledDate = DateTime.Now.AddDays(1) } ); _itineraryHelper = new ItineraryHelper(unitOfWork, mapper); var result = _itineraryHelper.Build(order); result.Itinerary.Count().Should().Be(1); }
public void Build_HomeFindingOrder_ShouldHaveOneViewingOnIntinerary() { Order order = new Order() { Id = "1", ServiceFlag = (int)ServiceCategory.AccompaniedHomeFinding, HomeFinding = new HomeFinding() }; order.HomeFinding.HomeFindingProperties.Add( new HomeFindingProperty() { ViewingDate = DateTime.Now.AddDays(1), Deleted = true } ); order.HomeFinding.HomeFindingProperties.Add( new HomeFindingProperty() { ViewingDate = null } ); order.HomeFinding.HomeFindingProperties.Add( new HomeFindingProperty() { ViewingDate = DateTime.Now.AddDays(1) } ); _itineraryHelper = new ItineraryHelper(unitOfWork, mapper); var result = _itineraryHelper.Build(order); result.Itinerary.Count().Should().Be(1); }
public void Build_NotHomeFindingOrder_ShouldHaveNoViewingsOnIntinerary() { Order order = new Order() { Id = "1", HomeFinding = new HomeFinding() }; order.HomeFinding.HomeFindingProperties.Add( new HomeFindingProperty() { ViewingDate = DateTime.Now.AddDays(1), Deleted = true } ); order.HomeFinding.HomeFindingProperties.Add( new HomeFindingProperty() { ViewingDate = null } ); order.HomeFinding.HomeFindingProperties.Add( new HomeFindingProperty() { ViewingDate = DateTime.Now.AddDays(1) } ); _itineraryHelper = new ItineraryHelper(unitOfWork, mapper); var result = _itineraryHelper.Build(order); result.Itinerary.Count().Should().Be(0); }
private OrdersTransfereeItineraryViewModel GetItineraryFromOrder(Order order) { ItineraryHelper itinHelper = new ItineraryHelper(_unitOfWork, _mapper); return(itinHelper.Build(order)); }
private OrdersTransfereeItineraryViewModel GetItineraryByOrderId(string id) { ItineraryHelper itinHelper = new ItineraryHelper(_unitOfWork, _mapper); return(itinHelper.Build(id)); }