Ejemplo n.º 1
0
        public async Task GetImageInfosAsync_ReturnsImageMetaData()
        {
            var client = new MarsRoverApiClient();
            var images = await client.GetImageInfosAsync(new DateTime(2019, 1, 1));

            Assert.That(images.Length, Is.GreaterThan(0));
        }
Ejemplo n.º 2
0
        private static async Task DownloadImages(string datesFileName)
        {
            var imageRepository  = new FileSystemImageRepository(AppConfiguration.ImageGalleryPath);
            var apiClient        = new MarsRoverApiClient();
            var nasaImageManager = new NasaImageManager(imageRepository, apiClient);

            nasaImageManager.ClearLocalImages();
            await nasaImageManager.DownloadImagesAsync(new FileDateListProvider(datesFileName)).ConfigureAwait(false);
        }
Ejemplo n.º 3
0
        public async Task DownloadImageAsync_DownloadsImages()
        {
            var client = new MarsRoverApiClient();
            var images = await client.GetImageInfosAsync(new DateTime(2019, 1, 1));

            var imageBytes = await client.DownloadImageAsync(images[0]);

            Assert.That(imageBytes.Length, Is.GreaterThan(0));
        }
Ejemplo n.º 4
0
        public async Task BenchmarkLoadingSequentially()
        {
            var marsRoverApiClient = new MarsRoverApiClient();

            List <Task> tasks = new List <Task>();

            foreach (var url in _urlList)
            {
                await marsRoverApiClient.DownloadImageAsync(new MarsImageInfo()
                {
                    ImageLink = url
                });
            }
        }
Ejemplo n.º 5
0
        public void BenchmarkLoadingInParallel()
        {
            var marsRoverApiClient = new MarsRoverApiClient();

            List <Task> tasks = new List <Task>();

            foreach (var url in _urlList)
            {
                tasks.Add(marsRoverApiClient.DownloadImageAsync(new MarsImageInfo()
                {
                    ImageLink = url
                }));
            }

            Task.WaitAll(tasks.ToArray());
        }
Ejemplo n.º 6
0
        public void DownloadImageAsync_WithNull_Throws()
        {
            var client = new MarsRoverApiClient();

            Assert.ThrowsAsync <ArgumentNullException>(() => client.DownloadImageAsync(null));
        }