public async Task GetMarsRoverPhotosByDate_ValidDate_ReturnPhotos_GreaterThan0()
        {
            var photoList = await _marsRaverPhotoRepo.GetMarsRoverPhotosByDate("2016-05-13");

            Assert.IsNotNull(photoList);
            Assert.Greater(photoList.Count, 0);
        }
Пример #2
0
        public async Task <IActionResult> GetMarsRoverPhotos()
        {
            try
            {
                var marsRoverPhotos = new List <MarsRoverPhoto>();

                string path = Path.Combine(Directory.GetCurrentDirectory(), @"Resources/dates.txt");

                StreamReader file = new StreamReader(path);
                string       line;

                while ((line = await file.ReadLineAsync()) != null)
                {
                    DateTime earthDate;
                    if (DateTime.TryParse(line, out earthDate))
                    {
                        if (!DateTime.MinValue.Equals(earthDate))
                        {
                            string strEarthDate = earthDate.ToString("yyyy-MM-dd");
                            var    photos       = await _marsRoverPhotoRepo.GetMarsRoverPhotosByDate(strEarthDate);

                            if (photos.Any())
                            {
                                marsRoverPhotos.AddRange(photos);
                                await DownloadFiles(strEarthDate, photos);
                            }
                        }
                    }
                }
                return(Ok(marsRoverPhotos));
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }