public void Build_WhenCalled_Should_Return_Two_Tasks()
        {
            // Arrange
            OrdersTransfereeItineraryViewModel itin = new OrdersTransfereeItineraryViewModel();
            var order = setUpOrder();

            svc = new Service()
            {
                OrderId       = order.Id,
                ServiceTypeId = 1,
                Notes         = "Integrated service test",
                Deleted       = false,
                ScheduledDate = DateTime.Now,
                Selected      = true
            };
            appt = new Appointment()
            {
                OrderId       = order.Id,
                ScheduledDate = DateTime.Now.AddDays(1),
                Deleted       = false,
                Description   = "Integrated appointment test"
            };
            //act
            order.Services.Add(svc);
            order.Appointments.Add(appt);
            Context.Orders.Add(order);
            Context.SaveChanges();
            Context.Entry(order).Reload();
            //assert
            var result = _itineraryHelper.Build(order);

            result.Itinerary.ToList().Count().Should().Equals(2);
        }
        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 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();
        }
Esempio n. 5
0
        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);
        }
Esempio n. 10
0
        private OrdersTransfereeItineraryViewModel GetItineraryFromOrder(Order order)
        {
            ItineraryHelper itinHelper = new ItineraryHelper(_unitOfWork, _mapper);

            return(itinHelper.Build(order));
        }
Esempio n. 11
0
        private OrdersTransfereeItineraryViewModel GetItineraryByOrderId(string id)
        {
            ItineraryHelper itinHelper = new ItineraryHelper(_unitOfWork, _mapper);

            return(itinHelper.Build(id));
        }