public void BudgetCreateOrUpdateTest() { using (MockContext context = MockContext.Start(this.GetType().FullName)) { var consumptionMgmtClient = ConsumptionTestUtilities.GetConsumptionManagementClient( context, new RecordedDelegatingHandler { StatusCodeToReturn = HttpStatusCode.OK }); consumptionMgmtClient.SubscriptionId = subscriptionId; var timePeriod = new BudgetTimePeriod { StartDate = new DateTime(2018, 2, 1), EndDate = new DateTime(2018, 11, 1), }; var budget = new Budget("Cost", 60, "Monthly", timePeriod); var budgetResponse = consumptionMgmtClient.Budgets.CreateOrUpdate(budgetName, budget); ValidateProperties(budgetResponse); Assert.Equal(budget.Amount, budgetResponse.Amount); Assert.Equal(budget.Category, budgetResponse.Category); Assert.Equal(budget.TimeGrain, budgetResponse.TimeGrain); Assert.Equal(budget.TimePeriod.StartDate, budgetResponse.TimePeriod.StartDate); Assert.Equal(budget.TimePeriod.EndDate, budgetResponse.TimePeriod.EndDate); } }
public void PriceSheetGetTopTest() { using (MockContext context = MockContext.Start(this.GetType())) { var consumptionMgmtClient = ConsumptionTestUtilities.GetConsumptionManagementClient( context, new RecordedDelegatingHandler { StatusCodeToReturn = HttpStatusCode.OK }); consumptionMgmtClient.SubscriptionId = subscriptionIdTest; var priceSheet = consumptionMgmtClient.PriceSheet.Get(top: top); ValidateProperties(priceSheet, true); } }
public void BudgetDeleteTest() { using (MockContext context = MockContext.Start(this.GetType().FullName)) { var consumptionMgmtClient = ConsumptionTestUtilities.GetConsumptionManagementClient( context, new RecordedDelegatingHandler { StatusCodeToReturn = HttpStatusCode.OK }); consumptionMgmtClient.SubscriptionId = subscriptionId; consumptionMgmtClient.Budgets.Delete("NETSDKTestBudget"); } }
public void PriceSheetGetByBillingPeriodTest() { using (MockContext context = MockContext.Start(this.GetType().FullName)) { var consumptionMgmtClient = ConsumptionTestUtilities.GetConsumptionManagementClient( context, new RecordedDelegatingHandler { StatusCodeToReturn = HttpStatusCode.OK }); consumptionMgmtClient.SubscriptionId = subscriptionId; var priceSheet = consumptionMgmtClient.PriceSheet.GetByBillingPeriod(billingPeriodName); ValidateProperties(priceSheet); } }
public void BudgetGetTest() { using (MockContext context = MockContext.Start(this.GetType().FullName)) { var consumptionMgmtClient = ConsumptionTestUtilities.GetConsumptionManagementClient( context, new RecordedDelegatingHandler { StatusCodeToReturn = HttpStatusCode.OK }); consumptionMgmtClient.SubscriptionId = subscriptionId; var budget = consumptionMgmtClient.Budgets.Get(budgetName); ValidateProperties(budget, true); } }
public void ListUsagesForBillingPeriodTest() { using (MockContext context = MockContext.Start(this.GetType().FullName)) { var consumptionMgmtClient = ConsumptionTestUtilities.GetConsumptionManagementClient( context, new RecordedDelegatingHandler { StatusCodeToReturn = HttpStatusCode.OK }); consumptionMgmtClient.SubscriptionId = subscriptionId; var usages = consumptionMgmtClient.UsageDetails.ListByBillingPeriod(billingPeriodName, top: 10); Assert.NotNull(usages); foreach (var item in usages) { ValidateProperties(item, expectedBillingPeriodId: billingPeriodName); } } }
public void ListReservationSummariesMonthlyWithReservationOrderIdAndReservationIdTest() { using (MockContext context = MockContext.Start(this.GetType())) { var consumptionMgmtClient = ConsumptionTestUtilities.GetConsumptionManagementClient( context, new RecordedDelegatingHandler { StatusCodeToReturn = HttpStatusCode.OK }); var reservationSummariesMonthly = consumptionMgmtClient.ReservationsSummaries.ListByReservationOrderAndReservation(reservationOrderId, reservationId, grain: "monthly"); Assert.NotNull(reservationSummariesMonthly); Assert.True(reservationSummariesMonthly.Any()); foreach (var item in reservationSummariesMonthly) { ValidateProperties(item); } } }
public void ListReservationDetailsWithReservationOrderIdTest() { using (MockContext context = MockContext.Start(this.GetType().FullName)) { var consumptionMgmtClient = ConsumptionTestUtilities.GetConsumptionManagementClient( context, new RecordedDelegatingHandler { StatusCodeToReturn = HttpStatusCode.OK }); var reservationDetails = consumptionMgmtClient.ReservationsDetails.ListByReservationOrder(reservationOrderId, startEndDateFilter); Assert.NotNull(reservationDetails); Assert.True(reservationDetails.Any()); foreach (var item in reservationDetails) { ValidateProperties(item); } } }
public void ListReservationSummariesDailyWithReservationOrderIdAndReservationIdTest() { using (MockContext context = MockContext.Start(this.GetType())) { var consumptionMgmtClient = ConsumptionTestUtilities.GetConsumptionManagementClient( context, new RecordedDelegatingHandler { StatusCodeToReturn = HttpStatusCode.OK }); var startEndDateFilter = "properties/UsageDate ge 2017-10-01 AND properties/UsageDate le 2017-12-07"; var reservationSummariesDaily = consumptionMgmtClient.ReservationsSummaries.ListByReservationOrderAndReservation(reservationOrderId, reservationId, grain: "daily", filter: startEndDateFilter); Assert.NotNull(reservationSummariesDaily); Assert.True(reservationSummariesDaily.Any()); foreach (var item in reservationSummariesDaily) { ValidateProperties(item); } } }
public void ListMarketplacesByBillingPeriodNextTest() { using (MockContext context = MockContext.Start(this.GetType())) { var consumptionMgmtClient = ConsumptionTestUtilities.GetConsumptionManagementClient( context, new RecordedDelegatingHandler { StatusCodeToReturn = HttpStatusCode.OK }); consumptionMgmtClient.SubscriptionId = subscriptionId; var marketplaceUsage = consumptionMgmtClient.Marketplaces.ListByBillingPeriodNext(listByBillingPeriodNexLink); Assert.NotNull(marketplaceUsage); Assert.True(marketplaceUsage.Any()); foreach (var item in marketplaceUsage) { ValidateProperties(item); } } }
public void ListUsagesWithExpandTest() { using (MockContext context = MockContext.Start(this.GetType().FullName)) { var consumptionMgmtClient = ConsumptionTestUtilities.GetConsumptionManagementClient(context, new RecordedDelegatingHandler { StatusCodeToReturn = HttpStatusCode.OK }); consumptionMgmtClient.SubscriptionId = subscriptionId; var usages = consumptionMgmtClient.UsageDetails.List( expand: "MeterDetails,AdditionalDetails", top: NumberOfItems); Assert.NotNull(usages); Assert.True(usages.Any()); Assert.True(NumberOfItems >= usages.Count()); foreach (var item in usages) { ValidateProperties(item, true, true); } } }
public void ListUsagesWithDateTimeFilterTest() { using (MockContext context = MockContext.Start(this.GetType().FullName)) { var consumptionMgmtClient = ConsumptionTestUtilities.GetConsumptionManagementClient( context, new RecordedDelegatingHandler { StatusCodeToReturn = HttpStatusCode.OK }); consumptionMgmtClient.SubscriptionId = subscriptionId; var dateTimeFilter = "properties/usageStart ge '2017-10-02' and properties/usageEnd le '2017-10-03'"; var usages = consumptionMgmtClient.UsageDetails.List(filter: dateTimeFilter, top: 10); Assert.NotNull(usages); foreach (var item in usages) { ValidateProperties(item, usageStart: new DateTime(2017, 10, 2), usageEnd: new DateTime(2017, 10, 3)); } } }
public void BudgetListTest() { using (MockContext context = MockContext.Start(this.GetType().FullName)) { var consumptionMgmtClient = ConsumptionTestUtilities.GetConsumptionManagementClient( context, new RecordedDelegatingHandler { StatusCodeToReturn = HttpStatusCode.OK }); consumptionMgmtClient.SubscriptionId = subscriptionId; var budgets = consumptionMgmtClient.Budgets.List(); Assert.NotNull(budgets); Assert.True(budgets.Any()); foreach (var b in budgets) { ValidateProperties(b, true); } } }
public void ListUsagesWithInstanceNameFilterTest() { using (MockContext context = MockContext.Start(this.GetType().FullName)) { var instanceName = "D1v2"; var filter = $"properties/instanceName eq '{instanceName}'"; var consumptionMgmtClient = ConsumptionTestUtilities.GetConsumptionManagementClient(context, new RecordedDelegatingHandler { StatusCodeToReturn = HttpStatusCode.OK }); consumptionMgmtClient.SubscriptionId = subscriptionId; var usages = consumptionMgmtClient.UsageDetails.List( filter: filter, top: NumberOfItems); Assert.NotNull(usages); Assert.True(usages.Any()); Assert.True(NumberOfItems >= usages.Count()); foreach (var item in usages) { ValidateProperties(item, instanceName: instanceName); } } }