public void Test_GetMarsRovers(int expectedRoverCount, int expectedCuriosityCameras) { var logger = new NullLogger <NasaApiClient>(); INasaApiSettings settings = new NasaApiSettings() { NasaApiUrl = "https://api.nasa.gov", MarsRoverApi = "mars-photos/api/v1/rovers", NasaApiKey = "b4rSDXQkrk4eKsUcU8zBfXykwe9cktbqg78Nmg3x" }; using (HttpClient _httpClient = new HttpClient()) { INasaApiClient client = new NasaApiClient(_httpClient, logger, settings); NasaMarsRovers nasaMarsRovers = client.GetRoversAsync().Result; Assert.NotNull(nasaMarsRovers); Assert.NotNull(nasaMarsRovers.Rovers); Assert.Equal(expectedRoverCount, nasaMarsRovers.Rovers.Count); if (nasaMarsRovers.Rovers.Count > 0) { Assert.Equal("Curiosity", nasaMarsRovers.Rovers[0].Name); Assert.Equal(expectedCuriosityCameras, nasaMarsRovers.Rovers[0].Cameras.Count); } } }
public void Test_GetPhotos02(string roverName, string date, int page, int expectedCount) { var logger = new NullLogger <NasaApiClient>(); INasaApiSettings settings = new NasaApiSettings() { NasaApiUrl = "https://api.nasa.gov", MarsRoverApi = "mars-photos/api/v1/rovers", NasaApiKey = "b4rSDXQkrk4eKsUcU8zBfXykwe9cktbqg78Nmg3x" }; using (HttpClient _httpClient = new HttpClient()) { INasaApiClient client = new NasaApiClient(_httpClient, logger, settings); IList <NasaMarsPhoto> nasaMarsPhotos = client.GetRoverPhotosAsync(roverName, date, page).Result; Assert.NotNull(nasaMarsPhotos); Assert.True(nasaMarsPhotos.Count < expectedCount); if (nasaMarsPhotos.Count > 0) { Assert.Equal(date, nasaMarsPhotos[0].EarthDate); } } }
public void Test_GetImage01(string imgSrc) { var logger = new NullLogger <NasaApiClient>(); INasaApiSettings settings = new NasaApiSettings() { NasaApiUrl = "https://api.nasa.gov", MarsRoverApi = "mars-photos/api/v1/rovers", NasaApiKey = "b4rSDXQkrk4eKsUcU8zBfXykwe9cktbqg78Nmg3x" }; using (HttpClient _httpClient = new HttpClient()) { INasaApiClient client = new NasaApiClient(_httpClient, logger, settings); byte[] images = client.GetRoverPhotoAsync(imgSrc).Result; Assert.NotNull(imgSrc); } }