コード例 #1
0
        public void UpdatePoliciesByBillingProfileTest()
        {
            var    something             = typeof(Billing.Tests.ScenarioTests.OperationsTests);
            string executingAssemblyPath = something.GetTypeInfo().Assembly.Location;

            HttpMockServer.RecordsDirectory = Path.Combine(Path.GetDirectoryName(executingAssemblyPath), "SessionRecords");

            using (MockContext context = MockContext.Start(this.GetType()))
            {
                // Create client
                var billingMgmtClient = BillingTestUtilities.GetBillingManagementClient(context, new RecordedDelegatingHandler {
                    StatusCodeToReturn = HttpStatusCode.OK
                });

                var policy = new Policy
                {
                    ReservationPurchases = ReservationPurchasesPolicy,
                    MarketplacePurchases = MarketplacePurchasesPolicy,
                    ViewCharges          = ViewChargesPolicy
                };

                // Update the policies
                var policies = billingMgmtClient.Policies.Update(BillingAccountName, BillingProfileName, policy);

                // Verify the response
                Assert.NotNull(policies);
                Assert.Equal(MarketplacePurchasesPolicy, policies.MarketplacePurchases);
                Assert.Equal(ReservationPurchasesPolicy, policies.ReservationPurchases);
                Assert.Equal(ViewChargesPolicy, policies.ViewCharges);
            }
        }
コード例 #2
0
        public void ValidateAddressTest()
        {
            var    something             = typeof(Billing.Tests.ScenarioTests.OperationsTests);
            string executingAssemblyPath = something.GetTypeInfo().Assembly.Location;

            HttpMockServer.RecordsDirectory = Path.Combine(Path.GetDirectoryName(executingAssemblyPath), "SessionRecords");

            using (MockContext context = MockContext.Start(this.GetType()))
            {
                // Address entity to validate
                var addressEntity = new AddressDetails
                {
                    AddressLine1 = "1 Microsoft Way",
                    City         = "Redmond",
                    Region       = "WA",
                    Country      = "US",
                    PostalCode   = "98052"
                };

                // Create client
                var billingMgmtClient = BillingTestUtilities.GetBillingManagementClient(context, new RecordedDelegatingHandler {
                    StatusCodeToReturn = HttpStatusCode.OK
                });

                // Validate Address
                var validateAddressResponse = billingMgmtClient.Address.Validate(addressEntity);

                // Verify that address is valid
                Assert.NotNull(validateAddressResponse);
                Assert.True(validateAddressResponse.Status == AddressValidationStatus.Valid);
            }
        }
コード例 #3
0
        public void ListProductsByInvoiceSectionTest()
        {
            var    something             = typeof(Billing.Tests.ScenarioTests.OperationsTests);
            string executingAssemblyPath = something.GetTypeInfo().Assembly.Location;

            HttpMockServer.RecordsDirectory = Path.Combine(Path.GetDirectoryName(executingAssemblyPath), "SessionRecords");

            using (MockContext context = MockContext.Start(this.GetType()))
            {
                // Create client
                var billingMgmtClient = BillingTestUtilities.GetBillingManagementClient(context, new RecordedDelegatingHandler {
                    StatusCodeToReturn = HttpStatusCode.OK
                });

                // Get the products
                var products = billingMgmtClient.Products.ListByInvoiceSection(BillingAccountName, BillingProfileName, InvoiceSectionName);

                // Verify the response
                Assert.NotNull(products);
                Assert.Equal(2, products.Value.Count);
                var product = Assert.Single(products.Value.Where(p => p.Name == ProductName));
                Assert.Contains(BillingProfileName, product.BillingProfileId);
                Assert.Contains(InvoiceSectionName, product.InvoiceSectionId);
                Assert.Equal(AvailabilityId, product.AvailabilityId);
                Assert.Equal(ProductName, product.Name);
            }
        }
コード例 #4
0
        public void ListInvoicesByBillingProfileTest()
        {
            var    something             = typeof(Billing.Tests.ScenarioTests.OperationsTests);
            string executingAssemblyPath = something.GetTypeInfo().Assembly.Location;

            HttpMockServer.RecordsDirectory = Path.Combine(Path.GetDirectoryName(executingAssemblyPath), "SessionRecords");

            using (MockContext context = MockContext.Start(this.GetType()))
            {
                // Create client
                var billingMgmtClient = BillingTestUtilities.GetBillingManagementClient(context, new RecordedDelegatingHandler {
                    StatusCodeToReturn = HttpStatusCode.OK
                });

                // Get the invoices
                var invoices = billingMgmtClient.Invoices.ListByBillingProfile(BillingAccountName, BillingProfileName, "2019-08-01", "2019-11-01");

                // Verify the response
                Assert.NotNull(invoices);
                var invoice = Assert.Single(invoices.Value);
                Assert.Contains(BillingProfileName, invoice.BillingProfileId);
                Assert.Equal(InvoiceNumber, invoice.Name);
                Assert.Equal(InvoiceStatus, invoice.Status);
                Assert.Equal(DueDate.Date, invoice.DueDate.Value.Date);
            }
        }
コード例 #5
0
        public void ValidateBillingSubscriptionsMoveEligibilityTest()
        {
            var    something             = typeof(Billing.Tests.ScenarioTests.OperationsTests);
            string executingAssemblyPath = something.GetTypeInfo().Assembly.Location;

            HttpMockServer.RecordsDirectory =
                Path.Combine(Path.GetDirectoryName(executingAssemblyPath), "SessionRecords");

            using (MockContext context = MockContext.Start(this.GetType()))
            {
                // Create client
                var billingMgmtClient = BillingTestUtilities.GetBillingManagementClient(context,
                                                                                        new RecordedDelegatingHandler {
                    StatusCodeToReturn = HttpStatusCode.OK
                });

                // Get the agreements
                var validateSubscriptionTransferEligibilityResult = billingMgmtClient.BillingSubscriptions.ValidateMove(
                    BillingAccountName,
                    new TransferBillingSubscriptionRequestProperties()
                {
                    DestinationInvoiceSectionId = DestinationInvoiceSectionId
                });

                // Verify the response
                Assert.NotNull(validateSubscriptionTransferEligibilityResult);
                Assert.NotNull(validateSubscriptionTransferEligibilityResult.IsMoveEligible);
                Assert.True(validateSubscriptionTransferEligibilityResult.IsMoveEligible.Value);
            }
        }
コード例 #6
0
        public void GetBillingSubscriptionTest()
        {
            var    something             = typeof(Billing.Tests.ScenarioTests.OperationsTests);
            string executingAssemblyPath = something.GetTypeInfo().Assembly.Location;

            HttpMockServer.RecordsDirectory = Path.Combine(Path.GetDirectoryName(executingAssemblyPath), "SessionRecords");

            using (MockContext context = MockContext.Start(this.GetType()))
            {
                // Create client
                var billingMgmtClient = BillingTestUtilities.GetBillingManagementClient(context, new RecordedDelegatingHandler {
                    StatusCodeToReturn = HttpStatusCode.OK
                });

                // Set the subscription id.
                billingMgmtClient.SubscriptionId = BillingSubscriptionName;

                // Get the agreements
                var billingSubscription = billingMgmtClient.BillingSubscriptions.Get(BillingAccountName);

                // Verify the response
                Assert.NotNull(billingSubscription);
                Assert.Contains(BillingProfileName, billingSubscription.BillingProfileId);
                Assert.Contains(InvoiceSectionName, billingSubscription.InvoiceSectionId);
                Assert.Contains(BillingSubscriptionName, billingSubscription.Name);
            }
        }
コード例 #7
0
        public void ListTransactionsByInvoiceTest()
        {
            var    something             = typeof(Billing.Tests.ScenarioTests.OperationsTests);
            string executingAssemblyPath = something.GetTypeInfo().Assembly.Location;

            HttpMockServer.RecordsDirectory = Path.Combine(Path.GetDirectoryName(executingAssemblyPath), "SessionRecords");

            using (MockContext context = MockContext.Start(this.GetType()))
            {
                // Create client
                var billingMgmtClient = BillingTestUtilities.GetBillingManagementClient(context, new RecordedDelegatingHandler {
                    StatusCodeToReturn = HttpStatusCode.OK
                });

                // Get the transactions
                var transactions = billingMgmtClient.Transactions.ListByInvoice(BillingAccountName, InvoiceId);

                // Verify the response
                Assert.NotNull(transactions);
                Assert.Equal(3, transactions.Count());
                var transaction = Assert.Single(transactions.Where(t => t.Name == TransactionName));
                Assert.Contains(BillingProfileName, transaction.BillingProfileId);
                Assert.Contains(InvoiceSectionName, transaction.InvoiceSectionId);
            }
        }
コード例 #8
0
        public void GetInvoiceBySubscriptionAndInvoiceNumberTest()
        {
            var    something             = typeof(Billing.Tests.ScenarioTests.OperationsTests);
            string executingAssemblyPath = something.GetTypeInfo().Assembly.Location;

            HttpMockServer.RecordsDirectory = Path.Combine(Path.GetDirectoryName(executingAssemblyPath), "SessionRecords");

            using (MockContext context = MockContext.Start(this.GetType()))
            {
                // Create client
                var billingMgmtClient = BillingTestUtilities.GetBillingManagementClient(context, new RecordedDelegatingHandler {
                    StatusCodeToReturn = HttpStatusCode.OK
                });

                // Get the invoice
                var invoice = billingMgmtClient.Invoices.GetBySubscriptionAndInvoiceId(InvoiceNumber);

                // Verify the response
                Assert.NotNull(invoice);
                Assert.Equal(SubscriptionId, invoice.SubscriptionId);
                Assert.Equal(InvoiceNumber, invoice.Name);
                Assert.Equal(InvoiceStatus, invoice.Status);
                Assert.True(invoice.IsMonthlyInvoice);
                Assert.NotNull(invoice.Documents);
                var document      = Assert.Single(invoice.Documents);
                var documentUrl   = new Uri(document.Url);
                var downloadToken = HttpUtility.ParseQueryString(documentUrl.Query).Get("downloadToken");
                Assert.Equal(DownloadToken, downloadToken);
            }
        }
コード例 #9
0
        public void ExpandBillingAccountByInvoiceSectionsTest()
        {
            var    something             = typeof(Billing.Tests.ScenarioTests.OperationsTests);
            string executingAssemblyPath = something.GetTypeInfo().Assembly.Location;

            HttpMockServer.RecordsDirectory = Path.Combine(Path.GetDirectoryName(executingAssemblyPath), "SessionRecords");

            using (MockContext context = MockContext.Start(this.GetType()))
            {
                // Create client
                var billingMgmtClient = BillingTestUtilities.GetBillingManagementClient(context, new RecordedDelegatingHandler {
                    StatusCodeToReturn = HttpStatusCode.OK
                });

                // Get the Billing Accounts and expand invoice sections
                var billingAccount = billingMgmtClient.BillingAccounts.Get(BillingAccountName, "billingProfiles/invoiceSections");

                // Verify the response
                Assert.NotNull(billingAccount);
                Assert.Equal(BillingAccountName, billingAccount.Name);
                var billingProfile = Assert.Single(billingAccount.BillingProfiles);
                Assert.Equal(BillingProfileName, billingProfile.Name);
                Assert.True(billingProfile.InvoiceSections.Count > 0);
            }
        }
コード例 #10
0
        public void CreateAndUpdateInvoiceSectionByBillingProfileTest()
        {
            var    something             = typeof(Billing.Tests.ScenarioTests.OperationsTests);
            string executingAssemblyPath = something.GetTypeInfo().Assembly.Location;

            HttpMockServer.RecordsDirectory =
                Path.Combine(Path.GetDirectoryName(executingAssemblyPath), "SessionRecords");
            var invoiceSectionName = "InvoiceSection-SDKTest-2";
            var displayName        = "InvoiceSection-SDKTest-2";
            var labels             = new Dictionary <string, string>
            {
                { "pcCode", "A123456" },
                { "costCategory", "Support" }
            };

            using (MockContext context = MockContext.Start(this.GetType()))
            {
                // Create client
                var billingMgmtClient = BillingTestUtilities.GetBillingManagementClient(context,
                                                                                        new RecordedDelegatingHandler {
                    StatusCodeToReturn = HttpStatusCode.OK
                });

                // Create the invoice sections
                var invoiceSection = billingMgmtClient.InvoiceSections.CreateOrUpdate(
                    BillingAccountName,
                    BillingProfileName,
                    invoiceSectionName,
                    new InvoiceSection
                {
                    DisplayName = displayName,
                    Labels      = labels
                });

                // Verify the response
                Assert.NotNull(invoiceSection);
                Assert.Equal(displayName, invoiceSection.DisplayName);
                Assert.NotNull(invoiceSection.Labels);
                Assert.Equal(labels.Count, invoiceSection.Labels.Count);
                Assert.Equal(labels["pcCode"], invoiceSection.Labels["pcCode"]);

                // Update the invoice section
                invoiceSection = billingMgmtClient.InvoiceSections.CreateOrUpdate(
                    BillingAccountName,
                    BillingProfileName,
                    invoiceSectionName,
                    new InvoiceSection
                {
                    DisplayName = NewInvoiceSectionDisplayName
                });

                // Verify the response
                Assert.NotNull(invoiceSection);
                Assert.Equal(NewInvoiceSectionDisplayName, invoiceSection.DisplayName);
                Assert.NotNull(invoiceSection.Labels);
                Assert.Equal(labels.Count, invoiceSection.Labels.Count);
                Assert.Equal(labels["pcCode"], invoiceSection.Labels["pcCode"]);
            }
        }
コード例 #11
0
 public void ListEnrollmentAccounts()
 {
     HttpMockServer.RecordsDirectory = GetSessionsDirectoryPath();
     using (MockContext context = MockContext.Start(this.GetType()))
     {
         var billingMgmtClient = BillingTestUtilities.GetBillingManagementClient(context, new RecordedDelegatingHandler {
             StatusCodeToReturn = HttpStatusCode.OK
         });
         var enrollmentAccounts = billingMgmtClient.EnrollmentAccounts.List().Value;
         Assert.NotNull(enrollmentAccounts);
         Assert.True(enrollmentAccounts.Any());
     }
 }
コード例 #12
0
ファイル: BillingPeriodsTests.cs プロジェクト: sjh37/aznetsdk
 public void ListBillingPeriodsTest()
 {
     HttpMockServer.RecordsDirectory = GetSessionsDirectoryPath();
     using (MockContext context = MockContext.Start(this.GetType().FullName))
     {
         var billingMgmtClient = BillingTestUtilities.GetBillingManagementClient(context, new RecordedDelegatingHandler {
             StatusCodeToReturn = HttpStatusCode.OK
         });
         var billingPeriods = billingMgmtClient.BillingPeriods.List();
         Assert.NotNull(billingPeriods);
         Assert.True(billingPeriods.Any());
     }
 }
コード例 #13
0
ファイル: InvoicesTests.cs プロジェクト: sjh37/aznetsdk
 public void ListInvoicesTest()
 {
     HttpMockServer.RecordsDirectory = GetSessionsDirectoryPath();
     using (MockContext context = MockContext.Start(this.GetType().FullName))
     {
         var billingMgmtClient = BillingTestUtilities.GetBillingManagementClient(context, new RecordedDelegatingHandler {
             StatusCodeToReturn = HttpStatusCode.OK
         });
         var invoices = billingMgmtClient.Invoices.List();
         Assert.NotNull(invoices);
         Assert.True(invoices.Any());
         Assert.DoesNotContain(invoices, x => x.DownloadUrl != null);
     }
 }
コード例 #14
0
 public void GetEnrollmentAccountWithName()
 {
     HttpMockServer.RecordsDirectory = GetSessionsDirectoryPath();
     using (MockContext context = MockContext.Start(this.GetType()))
     {
         var billingMgmtClient = BillingTestUtilities.GetBillingManagementClient(context, new RecordedDelegatingHandler {
             StatusCodeToReturn = HttpStatusCode.OK
         });
         var enrollmentAccount = billingMgmtClient.EnrollmentAccounts.Get(EnrollmentAccountName);
         Assert.NotNull(enrollmentAccount);
         Assert.Equal(EnrollmentAccountName, enrollmentAccount.Name);
         Assert.NotNull(enrollmentAccount.Name);
         Assert.NotNull(enrollmentAccount.PrincipalName);
     }
 }
コード例 #15
0
ファイル: InvoicesTests.cs プロジェクト: sjh37/aznetsdk
 public void GetLatestInvoice()
 {
     using (MockContext context = MockContext.Start(this.GetType().FullName))
     {
         var billingMgmtClient = BillingTestUtilities.GetBillingManagementClient(context, new RecordedDelegatingHandler {
             StatusCodeToReturn = HttpStatusCode.OK
         });
         var invoice = billingMgmtClient.Invoices.GetLatest();
         Assert.NotNull(invoice);
         Assert.False(string.IsNullOrWhiteSpace(invoice.DownloadUrl.Url));
         Assert.True(invoice.DownloadUrl.ExpiryTime.HasValue);
         Assert.NotNull(invoice.BillingPeriodIds);
         Assert.Equal(1, invoice.BillingPeriodIds.Count);
     }
 }
コード例 #16
0
ファイル: BillingPeriodsTests.cs プロジェクト: sjh37/aznetsdk
 public void ListBillingPeriodsWithQueryParametersTest()
 {
     HttpMockServer.RecordsDirectory = GetSessionsDirectoryPath();
     using (MockContext context = MockContext.Start(this.GetType().FullName))
     {
         var billingMgmtClient = BillingTestUtilities.GetBillingManagementClient(context, new RecordedDelegatingHandler {
             StatusCodeToReturn = HttpStatusCode.OK
         });
         var billingPeriods = billingMgmtClient.BillingPeriods.List(RangeFilter, null, 1);
         Assert.NotNull(billingPeriods);
         Assert.Single(billingPeriods);
         var billingPeriod = billingPeriods.First();
         Assert.True(billingPeriod.BillingPeriodStartDate.Value <= billingPeriod.BillingPeriodEndDate.Value);
         Assert.NotNull(billingPeriod.Name);
     }
 }
コード例 #17
0
        public void UpdateBillingAccountTest()
        {
            var    something             = typeof(Billing.Tests.ScenarioTests.OperationsTests);
            string executingAssemblyPath = something.GetTypeInfo().Assembly.Location;

            HttpMockServer.RecordsDirectory = Path.Combine(Path.GetDirectoryName(executingAssemblyPath), "SessionRecords");

            using (MockContext context = MockContext.Start(this.GetType()))
            {
                // Create client
                var billingMgmtClient = BillingTestUtilities.GetBillingManagementClient(context, new RecordedDelegatingHandler {
                    StatusCodeToReturn = HttpStatusCode.OK
                });
                var addressLine2 = "New Address line";
                var address      = new AddressDetails
                {
                    AddressLine1 = "1 Microsoft Way",
                    AddressLine2 = addressLine2,
                    CompanyName  = "Contoso Inc.",
                    City         = "Redmond",
                    Region       = "WA",
                    Country      = "US",
                    PostalCode   = "98052",
                    FirstName    = "First",
                    LastName     = "Last"
                };
                var displayName = Guid.NewGuid().ToString();

                // Get the Billing Accounts
                var billingAccount = billingMgmtClient.BillingAccounts.Update(
                    BillingAccountName,
                    new BillingAccountUpdateRequest
                {
                    DisplayName = displayName,
                    SoldTo      = address
                });

                // Verify the response
                Assert.NotNull(billingAccount);
                Assert.Equal(BillingAccountName, billingAccount.Name);
                Assert.NotNull(billingAccount.SoldTo);
                Assert.Equal(address.FirstName, billingAccount.SoldTo.FirstName);
                Assert.Equal(address.LastName, billingAccount.SoldTo.LastName);
                Assert.Equal(address.AddressLine1, billingAccount.SoldTo.AddressLine1);
                Assert.Equal(address.AddressLine2, billingAccount.SoldTo.AddressLine2);
            }
        }
コード例 #18
0
ファイル: BillingPeriodsTests.cs プロジェクト: sjh37/aznetsdk
 public void GetBillingPeriodWithName()
 {
     HttpMockServer.RecordsDirectory = GetSessionsDirectoryPath();
     using (MockContext context = MockContext.Start(this.GetType().FullName))
     {
         var billingMgmtClient = BillingTestUtilities.GetBillingManagementClient(context, new RecordedDelegatingHandler {
             StatusCodeToReturn = HttpStatusCode.OK
         });
         var billingPeriod = billingMgmtClient.BillingPeriods.Get(BillingPeriodName);
         Assert.NotNull(billingPeriod);
         Assert.Equal(BillingPeriodName, billingPeriod.Name);
         Assert.True(billingPeriod.BillingPeriodStartDate.Value <= billingPeriod.BillingPeriodEndDate.Value);
         Assert.NotNull(billingPeriod.Name);
         Assert.NotNull(billingPeriod.InvoiceIds);
         Assert.Equal(1, billingPeriod.InvoiceIds.Count);
     }
 }
コード例 #19
0
 public void GetInvoiceWithName()
 {
     HttpMockServer.RecordsDirectory = GetSessionsDirectoryPath();
     using (MockContext context = MockContext.Start(this.GetType()))
     {
         var billingMgmtClient = BillingTestUtilities.GetBillingManagementClient(context, new RecordedDelegatingHandler {
             StatusCodeToReturn = HttpStatusCode.OK
         });
         var invoice = billingMgmtClient.Invoices.Get(InvoiceName);
         Assert.NotNull(invoice);
         Assert.Equal(InvoiceName, invoice.Name);
         Assert.False(string.IsNullOrWhiteSpace(invoice.DownloadUrl.Url));
         Assert.True(invoice.DownloadUrl.ExpiryTime.HasValue);
         Assert.NotNull(invoice.BillingPeriodIds);
         Assert.Equal(1, invoice.BillingPeriodIds.Count);
     }
 }
コード例 #20
0
ファイル: InvoicesTests.cs プロジェクト: sjh37/aznetsdk
 public void ListInvoicesWithQueryParametersTest()
 {
     HttpMockServer.RecordsDirectory = GetSessionsDirectoryPath();
     using (MockContext context = MockContext.Start(this.GetType().FullName))
     {
         var billingMgmtClient = BillingTestUtilities.GetBillingManagementClient(context, new RecordedDelegatingHandler {
             StatusCodeToReturn = HttpStatusCode.OK
         });
         var invoices = billingMgmtClient.Invoices.List(DownloadUrlExpand, RangeFilter, null, 1);
         Assert.NotNull(invoices);
         Assert.Single(invoices);
         Assert.NotNull(invoices.First().DownloadUrl);
         var invoice = invoices.First();
         Assert.False(string.IsNullOrWhiteSpace(invoice.DownloadUrl.Url));
         Assert.True(invoice.DownloadUrl.ExpiryTime.HasValue);
     }
 }
コード例 #21
0
        public void UpdateProductAutoRenewTest()
        {
            var    something             = typeof(Billing.Tests.ScenarioTests.OperationsTests);
            string executingAssemblyPath = something.GetTypeInfo().Assembly.Location;

            HttpMockServer.RecordsDirectory = Path.Combine(Path.GetDirectoryName(executingAssemblyPath), "SessionRecords");
            var autoRenewOff = "Off";

            using (MockContext context = MockContext.Start(this.GetType()))
            {
                // Create client
                var billingMgmtClient = BillingTestUtilities.GetBillingManagementClient(context, new RecordedDelegatingHandler {
                    StatusCodeToReturn = HttpStatusCode.OK
                });

                // Get the products
                var productUpdateResult = billingMgmtClient.Products.Update(
                    BillingAccountName,
                    ProductName,
                    new Product
                {
                    AutoRenew = autoRenewOff
                });

                // Verify the response
                Assert.NotNull(productUpdateResult);
                Assert.NotNull(productUpdateResult.AutoRenew);
                Assert.Equal(autoRenewOff, productUpdateResult.AutoRenew);

                // restore
                var autoRenew = "On";
                productUpdateResult = billingMgmtClient.Products.Update(
                    BillingAccountName,
                    ProductName,
                    new Product
                {
                    AutoRenew = autoRenew
                });

                // verify restore
                Assert.NotNull(productUpdateResult);
                Assert.NotNull(productUpdateResult.AutoRenew);
                Assert.Equal(autoRenew, productUpdateResult.AutoRenew);
            }
        }
コード例 #22
0
        public void UpdateBillingSubscriptionsTest()
        {
            var    something             = typeof(Billing.Tests.ScenarioTests.OperationsTests);
            string executingAssemblyPath = something.GetTypeInfo().Assembly.Location;

            HttpMockServer.RecordsDirectory = Path.Combine(Path.GetDirectoryName(executingAssemblyPath), "SessionRecords");
            var costCenterNew = "CostCenterNew";

            using (MockContext context = MockContext.Start(this.GetType()))
            {
                // Create client
                var billingMgmtClient = BillingTestUtilities.GetBillingManagementClient(context, new RecordedDelegatingHandler {
                    StatusCodeToReturn = HttpStatusCode.OK
                });

                // Get the agreements
                var updatedBillingsubscription = billingMgmtClient.BillingSubscriptions.Update(
                    BillingAccountName,
                    new BillingSubscription
                {
                    CostCenter = costCenterNew
                });

                // Verify the response
                Assert.NotNull(updatedBillingsubscription);
                Assert.NotNull(updatedBillingsubscription.CostCenter);
                Assert.Equal(updatedBillingsubscription.CostCenter, costCenterNew);

                //restore
                var costCenterOld = "CostCenterOld";
                updatedBillingsubscription = billingMgmtClient.BillingSubscriptions.Update(
                    BillingAccountName,
                    new BillingSubscription
                {
                    CostCenter = costCenterOld
                });

                // Verify the response
                Assert.NotNull(updatedBillingsubscription);
                Assert.NotNull(updatedBillingsubscription.CostCenter);
                Assert.Equal(updatedBillingsubscription.CostCenter, costCenterOld);
            }
        }
コード例 #23
0
        public void MoveProductByInvoiceSectionTest()
        {
            var    something             = typeof(Billing.Tests.ScenarioTests.OperationsTests);
            string executingAssemblyPath = something.GetTypeInfo().Assembly.Location;

            HttpMockServer.RecordsDirectory = Path.Combine(Path.GetDirectoryName(executingAssemblyPath), "SessionRecords");

            using (MockContext context = MockContext.Start(this.GetType()))
            {
                // Create client
                var billingMgmtClient = BillingTestUtilities.GetBillingManagementClient(context, new RecordedDelegatingHandler {
                    StatusCodeToReturn = HttpStatusCode.OK
                });

                // Get the products
                var validateProductTransferEligibilityResult = billingMgmtClient.Products.ValidateMove(
                    BillingAccountName,
                    ProductName,
                    new TransferProductRequestProperties
                {
                    DestinationInvoiceSectionId = DestinationInvoiceSectionId
                });

                // Verify the response and make sure we can move product to destination InvoiceSection
                Assert.NotNull(validateProductTransferEligibilityResult);
                Assert.NotNull(validateProductTransferEligibilityResult.IsMoveEligible);
                if (validateProductTransferEligibilityResult.IsMoveEligible.Value)
                {
                    var movedProduct = billingMgmtClient.Products.Move(
                        BillingAccountName,
                        ProductName,
                        new TransferProductRequestProperties
                    {
                        DestinationInvoiceSectionId = DestinationInvoiceSectionId
                    });

                    // verify response
                    Assert.NotNull(movedProduct);
                    Assert.Equal(DestinationInvoiceSectionId, movedProduct.InvoiceSectionId);
                }
            }
        }
        public void GetBillingRoleAssignmentByBillingAccountTest()
        {
            var    something             = typeof(Billing.Tests.ScenarioTests.OperationsTests);
            string executingAssemblyPath = something.GetTypeInfo().Assembly.Location;

            HttpMockServer.RecordsDirectory = Path.Combine(Path.GetDirectoryName(executingAssemblyPath), "SessionRecords");

            using (MockContext context = MockContext.Start(this.GetType()))
            {
                // Create client
                var billingMgmtClient = BillingTestUtilities.GetBillingManagementClient(context, new RecordedDelegatingHandler {
                    StatusCodeToReturn = HttpStatusCode.OK
                });

                // Get the billing role assignment
                var billingRoleAssignment = billingMgmtClient.BillingRoleAssignments.GetByBillingAccount(BillingAccountName, BillingAccountRoleAssignmentName);

                // Verify the response
                Assert.NotNull(billingRoleAssignment);
                Assert.Equal(BillingAccountRoleAssignmentName, billingRoleAssignment.Name);
            }
        }
コード例 #25
0
        public void ListOperationsTest()
        {
            var    something             = typeof(Billing.Tests.ScenarioTests.OperationsTests);
            string executingAssemblyPath = something.GetTypeInfo().Assembly.Location;

            HttpMockServer.RecordsDirectory = Path.Combine(Path.GetDirectoryName(executingAssemblyPath), "SessionRecords");

            using (MockContext context = MockContext.Start(this.GetType()))
            {
                // Create client
                var billingMgmtClient = BillingTestUtilities.GetBillingManagementClient(context, new RecordedDelegatingHandler {
                    StatusCodeToReturn = HttpStatusCode.OK
                });

                // Get operations
                var operations = billingMgmtClient.Operations.List();

                // Verify operations are returned
                Assert.NotNull(operations);
                Assert.True(operations.Any());
            }
        }
コード例 #26
0
        public void DownloadModernInvoiceTest()
        {
            var    something             = typeof(Billing.Tests.ScenarioTests.OperationsTests);
            string executingAssemblyPath = something.GetTypeInfo().Assembly.Location;

            HttpMockServer.RecordsDirectory = Path.Combine(Path.GetDirectoryName(executingAssemblyPath), "SessionRecords");

            using (MockContext context = MockContext.Start(this.GetType()))
            {
                // Create client
                var billingMgmtClient = BillingTestUtilities.GetBillingManagementClient(context, new RecordedDelegatingHandler {
                    StatusCodeToReturn = HttpStatusCode.OK
                });

                // Download the invoice
                var downloadUrl = billingMgmtClient.Invoices.DownloadInvoice(BillingAccountName, InvoiceNumber, DownloadToken);

                // Verify the response
                Assert.NotNull(downloadUrl);
                Assert.NotNull(downloadUrl.Url);
            }
        }
        public void ListByBillingAccountTest()
        {
            var    something             = typeof(Billing.Tests.ScenarioTests.OperationsTests);
            string executingAssemblyPath = something.GetTypeInfo().Assembly.Location;

            HttpMockServer.RecordsDirectory = Path.Combine(Path.GetDirectoryName(executingAssemblyPath), "SessionRecords");

            using (MockContext context = MockContext.Start(this.GetType()))
            {
                // Create client
                var billingMgmtClient = BillingTestUtilities.GetBillingManagementClient(context, new RecordedDelegatingHandler {
                    StatusCodeToReturn = HttpStatusCode.OK
                });

                // Get the billing permissions
                var billingPermissions = billingMgmtClient.BillingPermissions.ListByBillingAccount(BillingAccountName);

                // Verify the response
                Assert.NotNull(billingPermissions);
                Assert.True(billingPermissions.Value.Count > 0);
                Assert.Contains(OrganizationViewPermission, billingPermissions.Value.First().Actions);
            }
        }
コード例 #28
0
        public void GetAvailableBalanceTest()
        {
            var    something             = typeof(Billing.Tests.ScenarioTests.OperationsTests);
            string executingAssemblyPath = something.GetTypeInfo().Assembly.Location;

            HttpMockServer.RecordsDirectory = Path.Combine(Path.GetDirectoryName(executingAssemblyPath), "SessionRecords");

            using (MockContext context = MockContext.Start(this.GetType()))
            {
                // Create client
                var billingMgmtClient = BillingTestUtilities.GetBillingManagementClient(context, new RecordedDelegatingHandler {
                    StatusCodeToReturn = HttpStatusCode.OK
                });

                // Get the available balance
                var availableBalance = billingMgmtClient.AvailableBalances.Get(BillingAccountName, BillingProfileName);

                // Verify the response
                Assert.NotNull(availableBalance);
                Assert.Equal(372.8, availableBalance.Amount.Value);
                Assert.Equal(BillingProfileCurrency, availableBalance.Amount.Currency);
            }
        }
コード例 #29
0
        public void ListBillingRoleDefinitionsByInvoiceSectionTest()
        {
            var    something             = typeof(Billing.Tests.ScenarioTests.OperationsTests);
            string executingAssemblyPath = something.GetTypeInfo().Assembly.Location;

            HttpMockServer.RecordsDirectory = Path.Combine(Path.GetDirectoryName(executingAssemblyPath), "SessionRecords");

            using (MockContext context = MockContext.Start(this.GetType()))
            {
                // Create client
                var billingMgmtClient = BillingTestUtilities.GetBillingManagementClient(context, new RecordedDelegatingHandler {
                    StatusCodeToReturn = HttpStatusCode.OK
                });

                // Get the billing role Definitions
                var billingRoleDefinitions = billingMgmtClient.BillingRoleDefinitions.ListByInvoiceSection(BillingAccountName, BillingProfileName, InvoiceSectionName);

                // Verify the response
                Assert.NotNull(billingRoleDefinitions);
                Assert.True(billingRoleDefinitions.Any());
                Assert.Contains(billingRoleDefinitions, role => role.Name == InvoiceSectionRoleDefinitionName);
            }
        }
コード例 #30
0
        public void ListInvoiceSectionsByBillingProfileTest()
        {
            var    something             = typeof(Billing.Tests.ScenarioTests.OperationsTests);
            string executingAssemblyPath = something.GetTypeInfo().Assembly.Location;

            HttpMockServer.RecordsDirectory = Path.Combine(Path.GetDirectoryName(executingAssemblyPath), "SessionRecords");

            using (MockContext context = MockContext.Start(this.GetType()))
            {
                // Create client
                var billingMgmtClient = BillingTestUtilities.GetBillingManagementClient(context, new RecordedDelegatingHandler {
                    StatusCodeToReturn = HttpStatusCode.OK
                });

                // List the invoice sections
                var invoiceSections = billingMgmtClient.InvoiceSections.ListByBillingProfile(BillingAccountName, BillingProfileName);

                // Verify the response
                Assert.NotNull(invoiceSections);
                Assert.Equal(7, invoiceSections.Value.Count);
                var invoiceSection = Assert.Single(invoiceSections.Value.Where(i => i.Name == InvoiceSectionName));
                Assert.Equal(InvoiceSectionDisplayName, invoiceSection.DisplayName);
            }
        }