Exemplo n.º 1
0
        public void TestCreateGetItineraryStopsByItineraryIdQuery_ItineraryDoesNotExist()
        {
            var project = new Project
            {
                ProjectId = 1,
            };
            var cityLocationType = new LocationType
            {
                LocationTypeId   = LocationType.City.Id,
                LocationTypeName = LocationType.City.Value
            };
            var location = new Location
            {
                LocationId     = 1,
                LocationName   = "city",
                LocationType   = cityLocationType,
                LocationTypeId = cityLocationType.LocationTypeId
            };
            var person1 = new Person
            {
                PersonId = 1,
                FullName = "person 1"
            };
            var participant1 = new Participant
            {
                ParticipantId = 1,
                PersonId      = person1.PersonId,
                Person        = person1
            };
            var itinerary = new Itinerary
            {
                ItineraryId = 1,
                Name        = "itinerary name",
                StartDate   = DateTimeOffset.UtcNow.AddDays(-100.0),
                EndDate     = DateTimeOffset.UtcNow.AddDays(100.0),
                ProjectId   = project.ProjectId,
                Project     = project
            };
            var stop = new ItineraryStop
            {
                DateArrive    = DateTimeOffset.UtcNow.AddDays(-10.0),
                DateLeave     = DateTimeOffset.UtcNow.AddDays(10.0),
                Destination   = location,
                DestinationId = location.LocationId,
                Itinerary     = itinerary,
                ItineraryId   = itinerary.ItineraryId,
                Name          = "stop"
            };

            stop.History.RevisedOn = DateTimeOffset.UtcNow;
            stop.Participants.Add(participant1);

            context.ItineraryStops.Add(stop);
            context.Locations.Add(location);
            context.LocationTypes.Add(cityLocationType);
            var results = ItineraryStopQueries.CreateGetItineraryStopsByItineraryIdQuery(context, itinerary.ItineraryId + 1).ToList();

            Assert.AreEqual(0, results.Count);
        }
 private IQueryable <ItineraryStopDTO> CreateGetItineraryStopsByItineraryIdAndProjectIdQuery(int projectId, int itineraryId)
 {
     return(ItineraryStopQueries.CreateGetItineraryStopsByItineraryIdQuery(this.Context, itineraryId).Where(x => x.ProjectId == projectId).OrderBy(x => x.ArrivalDate));
 }
 private IQueryable <ItineraryStopDTO> CreateGetItineraryStopDTOByIdQuery(int itineraryStopId)
 {
     return(ItineraryStopQueries.CreateGetItineraryStopsQuery(this.Context).Where(x => x.ItineraryStopId == itineraryStopId));
 }
Exemplo n.º 4
0
        public void TestCreateGetItineraryStopsQueryTest_CheckProperties()
        {
            var project = new Project
            {
                ProjectId = 1,
            };
            var cityLocationType = new LocationType
            {
                LocationTypeId   = LocationType.City.Id,
                LocationTypeName = LocationType.City.Value
            };
            var location = new Location
            {
                LocationId     = 1,
                LocationName   = "city",
                LocationType   = cityLocationType,
                LocationTypeId = cityLocationType.LocationTypeId
            };
            var person1 = new Person
            {
                PersonId = 1,
                FullName = "person 1"
            };
            var participant1 = new Participant
            {
                ParticipantId = 1,
                PersonId      = person1.PersonId,
                Person        = person1
            };
            var itinerary = new Itinerary
            {
                ItineraryId = 1,
                Name        = "itinerary name",
                StartDate   = DateTimeOffset.UtcNow.AddDays(-100.0),
                EndDate     = DateTimeOffset.UtcNow.AddDays(100.0),
                ProjectId   = project.ProjectId,
                Project     = project
            };
            var stop = new ItineraryStop
            {
                DateArrive    = DateTimeOffset.UtcNow.AddDays(-10.0),
                DateLeave     = DateTimeOffset.UtcNow.AddDays(10.0),
                Destination   = location,
                DestinationId = location.LocationId,
                Itinerary     = itinerary,
                ItineraryId   = itinerary.ItineraryId,
                Name          = "stop",
                TimezoneId    = "timezone"
            };

            stop.History.RevisedOn = DateTimeOffset.UtcNow;
            stop.Participants.Add(participant1);

            context.ItineraryStops.Add(stop);
            context.Locations.Add(location);
            context.LocationTypes.Add(cityLocationType);
            var results = ItineraryStopQueries.CreateGetItineraryStopsQuery(context).ToList();

            Assert.AreEqual(1, results.Count);

            var firstResult = results.First();

            Assert.AreEqual(stop.TimezoneId, firstResult.TimezoneId);
            Assert.AreEqual(stop.DateArrive, firstResult.ArrivalDate);
            Assert.AreEqual(stop.DateLeave, firstResult.DepartureDate);
            Assert.AreEqual(itinerary.ItineraryId, firstResult.ItineraryId);
            Assert.AreEqual(stop.ItineraryStopId, firstResult.ItineraryStopId);
            Assert.AreEqual(stop.History.RevisedOn, firstResult.LastRevisedOn);
            Assert.AreEqual(stop.Name, firstResult.Name);
            Assert.AreEqual(1, firstResult.ParticipantsCount);
            Assert.AreEqual(project.ProjectId, firstResult.ProjectId);

            Assert.IsNotNull(firstResult.DestinationLocation);
            var destination = firstResult.DestinationLocation;

            Assert.AreEqual(location.LocationId, destination.Id);

            //check participants
            Assert.AreEqual(1, firstResult.Participants.Count());
            var firstParticipant = firstResult.Participants.First();

            Assert.AreEqual(participant1.ParticipantId, firstParticipant.ParticipantId);
            Assert.AreEqual(person1.PersonId, firstParticipant.PersonId);
            Assert.AreEqual(person1.FullName, firstParticipant.FullName);
            Assert.AreEqual(-1, firstParticipant.ItineraryInformationId);
            Assert.IsNull(firstParticipant.TravelingFrom);
        }