Esempio n. 1
0
        /// <summary>
        /// Handles the response from the NASA API.
        /// </summary>
        /// <param name="nasaResponse"></param>
        /// <returns></returns>
        public ImageFileResponse HandleNasaResponse(NasaPhotoResponse nasaResponse)
        {
            var imageFileResponse = new ImageFileResponse
            {
                count        = nasaResponse.Photos.Count,
                isSuccessful = false
            };

            if (!nasaResponse.Photos.Any())
            {
                return(imageFileResponse);
            }

            // get the date from the first photo and put on the end of the path
            _path = $"{_path}/{nasaResponse.Photos[0].EarthDate:yyyyMMdd}";

            // Create directory if it doesn't already exist
            if (!System.IO.Directory.Exists(_path))
            {
                System.IO.Directory.CreateDirectory(_path);
            }

            // Process each image concurrently
            Parallel.ForEach(nasaResponse.Photos, photo => SavePhoto(photo));

            return(new ImageFileResponse
            {
                count = nasaResponse.Photos.Count,
                isSuccessful = true,
                location = _path
            });
        }
Esempio n. 2
0
        public void ConstructorPopulatesAllPropertiesIfMosaicGenerated()
        {
            var project  = CreateProjectStructureHelper(true, true, true);
            var response = new ImageFileResponse()
            {
                File = new ImageFileIndexStructure()
                {
                    Id = project.LargeFileId, FileName = "ImageFile.jpg"
                }
            };

            MockMakerClient.Setup(x => x.ReadImageFile(It.Is <string>(p => p.Equals(project.LargeFileId)))).Returns(response);

            var projectCard = new ProjectCardModel(MockMakerClient.Object, project);

            Assert.AreEqual(response.File.FileName, projectCard.MasterFileName);
        }