Example #1
0
        public async void GetAll()
        {
            var tripServiceMock = new Mock <ITripService> ();
            var pathServiceMock = new Mock <IPathService> ();

            string lineID            = "Line:1";
            string pathID            = "Path:1";
            string tripDepartureTime = "20:12:10";

            var trip  = new Trip(lineID, pathID, tripDepartureTime);
            var trips = new List <Trip> ()
            {
                trip
            };

            var tripDTO  = new TripDTO(trip.Id.AsGuid(), new LineId(lineID), new PathId(pathID), tripDepartureTime);
            var tripsDTO = new List <TripDTO> ()
            {
                tripDTO
            };

            tripServiceMock.Setup(_ => _.GetAll()).ReturnsAsync(tripsDTO);

            var controller = new TripController(tripServiceMock.Object, pathServiceMock.Object);

            var actual = await controller.GetAll();

            Assert.Equal(tripsDTO, actual.Value);
        }
Example #2
0
        public async Task<IActionResult> OnGet()
        {
            var token = HttpContext.Request.Cookies["TraverlApp.fun.Token"];
            Trips = new List<TravelAppModels.Models.Trip>();
            var alltrips = ((await _trips.GetAll(token)) as ObjectResult).Value as TravelAppModels.Models.Trip[];

            foreach(var trip in alltrips)
            {
                trip.Photos = new Photo[trip.PhotoIds?.Length ?? 0] ;
                for (int i = 0; i < (trip.PhotoIds?.Length ?? 0); i++)
                {
                    trip.Photos[i] = ((await _photos.Get(trip.PhotoIds[i], token)) as ObjectResult).Value as Photo;
                }
                Trips.Add(trip);
            }

            return Page();
        }