Example #1
0
        public void TestDoValidateCreate_ItineraryStopArrivalDateIsAfterItineraryEndDate()
        {
            var timezoneId         = "timezone";
            var itineraryStartDate = DateTimeOffset.UtcNow.AddDays(-100.0);
            var itineraryEndDate   = DateTimeOffset.UtcNow.AddDays(100.0);
            var stopArrivalDate    = DateTimeOffset.UtcNow.AddDays(-10.0);
            var stopDepartureDate  = DateTimeOffset.UtcNow.AddDays(10.0);

            EcaItineraryStopValidationEntity        model        = null;
            Func <EcaItineraryStopValidationEntity> createEntity = () =>
            {
                model = new EcaItineraryStopValidationEntity(
                    itineraryStartDate: itineraryStartDate,
                    itineraryEndDate: itineraryEndDate,
                    itineraryStopArrivalDate: stopArrivalDate,
                    itineraryStopDepartureDate: stopDepartureDate,
                    timezoneId: timezoneId
                    );
                return(model);
            };

            Assert.AreEqual(0, validator.DoValidateCreate(createEntity()).Count());
            stopArrivalDate   = itineraryEndDate.AddDays(1.0);
            stopDepartureDate = stopArrivalDate;

            var entity           = createEntity();
            var validationErrors = validator.DoValidateCreate(entity).ToList();

            Assert.AreEqual(2, validationErrors.Count);
            Assert.AreEqual(ItineraryStopServiceValidator.ITINERARY_STOP_ARRIVAL_DATE_IS_NOT_WITHIN_ITINERARY_DATES, validationErrors.First().ErrorMessage);
            Assert.AreEqual(PropertyHelper.GetPropertyName <EcaItineraryStop>(x => x.ArrivalDate), validationErrors.First().Property);

            Assert.AreEqual(ItineraryStopServiceValidator.ITINERARY_STOP_DEPARTURE_DATE_IS_NOT_WITHIN_ITINERARY_DATES, validationErrors.Last().ErrorMessage);
            Assert.AreEqual(PropertyHelper.GetPropertyName <EcaItineraryStop>(x => x.DepartureDate), validationErrors.Last().Property);
        }
        public void TestConstructor()
        {
            var itineraryStartDate = DateTimeOffset.UtcNow.AddDays(-100.0);
            var itineraryEndDate   = DateTimeOffset.UtcNow.AddDays(100.0);
            var stopArrivalDate    = DateTimeOffset.UtcNow.AddDays(-10.0);
            var stopDepartureDate  = DateTimeOffset.UtcNow.AddDays(10.0);
            var timezoneId         = "timezone";

            var model = new EcaItineraryStopValidationEntity(itineraryStartDate, itineraryEndDate, stopArrivalDate, stopDepartureDate, timezoneId);

            Assert.AreEqual(itineraryStartDate, model.ItineraryStartDate);
            Assert.AreEqual(itineraryEndDate, model.ItineraryEndDate);
            Assert.AreEqual(stopArrivalDate, model.ItineraryStopArrivalDate);
            Assert.AreEqual(stopDepartureDate, model.ItineraryStopDepartureDate);
            Assert.AreEqual(timezoneId, model.TimezoneId);
        }