public void UpdateExistingBillingProfileTest()
        {
            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 poNumber           = "8901234";
                var displayName        = "UpdatedBillingProfileDisplayName";
                var billingProfileName = "Test_BillingProfile2020GA";

                // Get the billing profile
                var billingProfile = billingMgmtClient.BillingProfiles.CreateOrUpdate(
                    BillingAccountName,
                    billingProfileName,
                    new BillingProfile
                {
                    DisplayName = displayName,
                    PoNumber    = poNumber
                });

                // Verify the response
                Assert.NotNull(billingProfile);
                Assert.Equal(billingProfileName, billingProfile.Name);
                Assert.Equal(BillingProfileCurrency, billingProfile.Currency);
                Assert.Equal(displayName, billingProfile.DisplayName);
                Assert.Equal(poNumber, billingProfile.PoNumber);
            }
        }
        public void ListPaymentMethodsByBillingProfileTest()
        {
            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 payment methods
                var paymentMethods = billingMgmtClient.PaymentMethods.ListByBillingProfile(BillingAccountName, BillingProfileName);

                // Verify the response
                Assert.NotNull(paymentMethods);
                Assert.Equal(2, paymentMethods.Count());
                var credit = Assert.Single(paymentMethods.Where(pm => pm.PaymentMethodType == "Credits"));
                Assert.Equal(CreditsPaymentMethod, credit.Details);
                Assert.Equal(ExpirationDate, credit.Expiration);
                Assert.Equal(PaymentMethodCurrency, credit.Currency);
            }
        }
        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.Count());
                var invoiceSection = Assert.Single(invoiceSections.Where(i => i.Name == InvoiceSectionName));
                Assert.Equal(InvoiceSectionDisplayName, invoiceSection.DisplayName);
            }
        }
        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);
            }
        }
Beispiel #5
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);
            }
        }
Beispiel #6
0
        public void ListAgreementsByBillingAccountTest()
        {
            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 agreements = billingMgmtClient.Agreements.ListByBillingAccount(BillingAccountName);

                // Verify the response
                Assert.NotNull(agreements);
                Assert.NotEmpty(agreements);
                var agreement = Assert.Single(agreements);
                Assert.NotNull(agreement.AcceptanceMode);
                Assert.NotNull(agreement.AgreementLink);
                Assert.NotNull(agreement.Category);
                Assert.NotNull(agreement.EffectiveDate);
                Assert.NotNull(agreement.ExpirationDate);
                Assert.NotNull(agreement.Name);
                Assert.NotNull(agreement.Status);
                Assert.Equal(AgreementStatus, agreement.Status);
                Assert.Equal(AgreementAcceptanceMode, agreement.AcceptanceMode);
                Assert.Equal(AgreementCategory, agreement.Category);
            }
        }
Beispiel #7
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.Value);
                Assert.Equal(BillingProfileName, billingProfile.Name);
                Assert.True(billingProfile.InvoiceSections.Value.Count > 0);
            }
        }
Beispiel #8
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);
            }
        }
Beispiel #9
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.Count());
                var product = Assert.Single(products.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);
            }
        }
Beispiel #10
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);
            }
        }
Beispiel #11
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);
            }
        }
Beispiel #12
0
        public void ListInvoiceSectionsByCreateSubscriptionPermissionTest()
        {
            var    something             = typeof(Billing.Tests.ScenarioTests.OperationsTests);
            string executingAssemblyPath = something.GetTypeInfo().Assembly.Location;

            HttpMockServer.RecordsDirectory = Path.Combine(Path.GetDirectoryName(executingAssemblyPath), "SessionRecords");
            var invoiceSectionDisplayName = "CGPK-BEXW-PJA-TGB";

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

                // Get the Billing Accounts
                var invoiceSections = billingMgmtClient.BillingAccounts.ListInvoiceSectionsByCreateSubscriptionPermission(BillingAccountName);

                // Verify the response
                Assert.NotNull(invoiceSections);
                Assert.Equal(9, invoiceSections.Count());
                var invoiceSection =
                    invoiceSections.Where(i => i.InvoiceSectionDisplayName == invoiceSectionDisplayName);
            }
        }
        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);
            }
        }
Beispiel #14
0
        public void ListTransactionsByInvoiceSectionTest()
        {
            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.ListByInvoiceSection(BillingAccountName, BillingProfileName, InvoiceSectionName, "2018-12-01", "2019-11-18");

                // Verify the response
                Assert.NotNull(transactions);
                Assert.Equal(2, transactions.Value.Count);
                var transaction = Assert.Single(transactions.Value.Where(t => t.Name == TransactionName));
                Assert.Contains(BillingProfileName, transaction.BillingProfileId);
                Assert.Contains(InvoiceSectionName, transaction.InvoiceSectionId);
            }
        }
        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"]);
            }
        }
Beispiel #16
0
 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());
     }
 }
 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());
     }
 }
Beispiel #18
0
 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);
     }
 }
Beispiel #19
0
 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);
     }
 }
 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);
     }
 }
Beispiel #21
0
 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);
     }
 }
Beispiel #22
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);
            }
        }
Beispiel #23
0
 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);
     }
 }
Beispiel #24
0
 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);
     }
 }
Beispiel #25
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);
     }
 }
Beispiel #26
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);
            }
        }
Beispiel #27
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);
            }
        }
Beispiel #28
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 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 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);
            }
        }