public async Task TestGetVersionIndexFile_AllServices() { // ARRANGE PriceListClient client = new PriceListClient(); GetOfferIndexFileResponse response = await client.GetOfferIndexFileAsync(); ConcurrentBag <VersionIndex> indices = new ConcurrentBag <VersionIndex>(); // ACT IEnumerable <Task> tasks = response.OfferIndexFile.Offers.Select(async x => { GetVersionIndexResponse versionIndexResponse = await client.GetVersionIndexAsync(new GetVersionIndexRequest(x.Value)); if (versionIndexResponse != null && versionIndexResponse.VersionIndex != null) { indices.Add(versionIndexResponse.VersionIndex); } }); await Task.WhenAll(tasks); // ASSERT Assert.Equal(response.OfferIndexFile.Offers.Where(x => !String.IsNullOrEmpty(x.Value.VersionIndexUrl)).Count(), indices.Count); Assert.All(indices, x => Assert.NotNull(x)); }
public async Task TestGetOfferIndexFile_WithoutRequest() { // ARRANGE PriceListClient client = new PriceListClient(); // ACT GetOfferIndexFileResponse response = await client.GetOfferIndexFileAsync(); // ASSERT Assert.True(!response.IsError()); Assert.NotNull(response.OfferIndexFile); }
public async Task TestGetOfferIndexFile_WithRequest() { // ARRANGE PriceListClient client = new PriceListClient(); GetOfferIndexFileRequest request = new GetOfferIndexFileRequest("/offers/v1.0/aws/index.json"); // ACT GetOfferIndexFileResponse response = await client.GetOfferIndexFileAsync(request); // ASSERT Assert.True(!response.IsError()); Assert.NotNull(response.OfferIndexFile); }
public async Task TestGetVerionIndexFile_AmazonEC2_WithOffer() { // ARRANGE PriceListClient client = new PriceListClient(); GetOfferIndexFileResponse response = await client.GetOfferIndexFileAsync(); Offer offer = response.OfferIndexFile.Offers["AmazonEC2"]; // ACT GetVersionIndexResponse versionResponse = await client.GetVersionIndexAsync(new GetVersionIndexRequest(offer)); // ASSERT Assert.Equal(200, (int)versionResponse.HttpStatusCode); }
public async Task TestGetVerionIndexFile_AmazonEC2_WithRelativePath() { // ARRANGE PriceListClient client = new PriceListClient(); GetOfferIndexFileResponse response = await client.GetOfferIndexFileAsync(); string versionIndexUrl = response.OfferIndexFile.Offers["AmazonEC2"].VersionIndexUrl; // ACT GetVersionIndexResponse versionResponse = await client.GetVersionIndexAsync(new GetVersionIndexRequest(versionIndexUrl)); // ASSERT Assert.Equal(200, (int)versionResponse.HttpStatusCode); }
public async Task GetSavingsPlan_RegionIndex_ECS() { // ARRANGE PriceListClient client = new PriceListClient(); GetOfferIndexFileRequest indexRequest = new GetOfferIndexFileRequest(); GetOfferIndexFileResponse indexResponse = await client.GetOfferIndexFileAsync(indexRequest); GetSavingsPlanIndexFileRequest spRegionIndexRequest = new GetSavingsPlanIndexFileRequest(indexResponse.OfferIndexFile.Offers["AmazonECS"].CurrentSavingsPlanIndexUrl); // ACT GetSavingsPlanIndexFileResponse spRegionIndexResponse = await client.GetSavingsPlanRegionIndexAsync(spRegionIndexRequest); // ASSERT Assert.Equal(200, (int)spRegionIndexResponse.HttpStatusCode); }
public async Task GetSavingsPlan_Offer_UsEast1_EC2() { // ARRANGE PriceListClient client = new PriceListClient(); GetOfferIndexFileRequest indexRequest = new GetOfferIndexFileRequest(); GetOfferIndexFileResponse indexResponse = await client.GetOfferIndexFileAsync(indexRequest); GetSavingsPlanIndexFileRequest spRegionIndexRequest = new GetSavingsPlanIndexFileRequest(indexResponse.OfferIndexFile.Offers["AmazonEC2"].CurrentSavingsPlanIndexUrl); GetSavingsPlanIndexFileResponse spRegionIndexResponse = await client.GetSavingsPlanRegionIndexAsync(spRegionIndexRequest); GetSavingsPlanRequest spRequest = new GetSavingsPlanRequest(spRegionIndexResponse.RegionIndex.Regions.First(x => x.RegionCode.Equals("us-east-1")).VersionUrl); // ACT GetSavingsPlanResponse spResponse = await client.GetSavingsPlanAsync(spRequest); // ASSERT Assert.Equal(200, (int)spResponse.HttpStatusCode); Assert.NotNull(spResponse.SavingsPlan.Products); Assert.True(spResponse.SavingsPlan.Products.Any()); Assert.NotNull(spResponse.SavingsPlan.Terms); Assert.NotNull(spResponse.SavingsPlan.Terms.SavingsPlan); Assert.True(spResponse.SavingsPlan.Terms.SavingsPlan.Any()); }