From 5c141b7450434bae7b082a6936bb1432451d9c9d Mon Sep 17 00:00:00 2001 From: Piotr Pabis Date: Fri, 26 Jan 2024 09:36:36 +0100 Subject: [PATCH] feat: fixes for new version --- Tests/SubscriptionComponentsTests.cs | 15 ++++------- Tests/SubscriptionTests.cs | 40 +++++++++++++--------------- 2 files changed, 23 insertions(+), 32 deletions(-) diff --git a/Tests/SubscriptionComponentsTests.cs b/Tests/SubscriptionComponentsTests.cs index 6630233..a225f40 100644 --- a/Tests/SubscriptionComponentsTests.cs +++ b/Tests/SubscriptionComponentsTests.cs @@ -42,9 +42,7 @@ await _client.SubscriptionsController.CreateSubscriptionAsync( var onOffComponent = new OnOffComponent($"247Support{randomString}", unitPrice: OnOffComponentUnitPrice.FromString("100")); - var onOffComponentResponse = await _client.ComponentsController.CreateComponentCreateComponentAsync((int)productFamilyId, - ComponentKindPath.OnOffComponents, - CreateComponentBody.FromCreateOnOffComponent(new CreateOnOffComponent(onOffComponent))); + var onOffComponentResponse = await _client.ComponentsController.CreateOnOffComponentAsync((int)productFamilyId, new CreateOnOffComponent(onOffComponent)); onOffComponentResponse.Component.Id.Should().NotBeNull(); @@ -109,20 +107,17 @@ await _client.SubscriptionsController.CreateSubscriptionAsync( PricingScheme.PerUnit, unitPrice: QuantityBasedComponentUnitPrice.FromString("10,23"), allowFractionalQuantities: true); - var quantityComponentResponse = await _client.ComponentsController.CreateComponentAsync( + var quantityComponentResponse = await _client.ComponentsController.CreateQuantityBasedComponentAsync( (int)productFamilyId, - ComponentKindPath.QuantityBasedComponents, - CreateComponentBody.FromCreateQuantityBasedComponent( - new CreateQuantityBasedComponent(quantityComponent))); + new CreateQuantityBasedComponent(quantityComponent)); quantityComponentResponse.Component.Id.Should().NotBeNull(); var onOffComponent = new OnOffComponent($"247Support{randomString}", unitPrice: OnOffComponentUnitPrice.FromString("100")); - var onOffComponentResponse = await _client.ComponentsController.CreateComponentAsync((int)productFamilyId, - ComponentKindPath.OnOffComponents, - CreateComponentBody.FromCreateOnOffComponent(new CreateOnOffComponent(onOffComponent))); + var onOffComponentResponse = await _client.ComponentsController.CreateOnOffComponentAsync((int)productFamilyId, + new CreateOnOffComponent(onOffComponent)); onOffComponentResponse.Component.Id.Should().NotBeNull(); diff --git a/Tests/SubscriptionTests.cs b/Tests/SubscriptionTests.cs index dc68f42..817e3b1 100644 --- a/Tests/SubscriptionTests.cs +++ b/Tests/SubscriptionTests.cs @@ -33,14 +33,14 @@ public async Task CreateSubscription_BasicScenarioData_ShouldSuccess() var customerResponse = await CreationUtils.CreateCustomer(_client); - var paymentProfile = await CreationUtils.CreatePaymentProfile(customerResponse.Customer.Id, _client); + var paymentProfileId = await CreationUtils.CreatePaymentProfile(customerResponse.Customer.Id, _client); var subscription = new CreateSubscription { CustomerId = customerResponse.Customer.Id, ProductId = productResponse.Product.Id, PaymentCollectionMethod = PaymentCollectionMethod.Automatic, - PaymentProfileId = paymentProfile.PaymentProfile.Id, + PaymentProfileId = paymentProfileId, DunningCommunicationDelayEnabled = false, SkipBillingManifestTaxes = false }; @@ -50,7 +50,7 @@ await _client.SubscriptionsController.CreateSubscriptionAsync( new CreateSubscriptionRequest(subscription)); subscriptionResponse.Subscription.Id.Should().NotBeNull(); - await CleanupUtils.ExecuteBasicSubscriptionCleanup(subscriptionResponse, customerResponse, paymentProfile, productResponse, _client); + await CleanupUtils.ExecuteBasicSubscriptionCleanup(subscriptionResponse, customerResponse, paymentProfileId, productResponse, _client); } [Fact] @@ -66,9 +66,8 @@ public async Task var meteredComponent = new MeteredComponent($"ApiCalls{randomString}", $"api call {randomString}", PricingScheme.PerUnit, unitPrice: MeteredComponentUnitPrice.FromString("1")); - var componentResponse = await _client.ComponentsController.CreateComponentAsync((int)productFamilyId, - ComponentKindPath.MeteredComponents, - CreateComponentBody.FromCreateMeteredComponent(new CreateMeteredComponent(meteredComponent))); + var componentResponse = await _client.ComponentsController.CreateMeteredComponentAsync((int)productFamilyId, + new CreateMeteredComponent(meteredComponent)); componentResponse.Component.Id.Should().NotBeNull(); @@ -93,7 +92,7 @@ public async Task var customer = await CreationUtils.CreateCustomer(_client); - var paymentProfile = await CreationUtils.CreatePaymentProfile(customer.Customer.Id, _client); + var paymentProfileId = await CreationUtils.CreatePaymentProfile(customer.Customer.Id, _client); var initialBillingDate = DateTime.Now.AddDays(20); @@ -104,7 +103,7 @@ public async Task CustomerId = customer.Customer.Id, ProductId = product.Product.Id, PaymentCollectionMethod = PaymentCollectionMethod.Automatic, - PaymentProfileId = paymentProfile.PaymentProfile.Id, + PaymentProfileId = paymentProfileId, DunningCommunicationDelayEnabled = false, SkipBillingManifestTaxes = false, Components = new List() @@ -122,7 +121,7 @@ await _client.Invoking(c => c.SubscriptionsController.CreateSubscriptionAsync( .ThrowAsync() .Where(e => e.ResponseCode == 422 && e.Errors.Any(a => a.Contains("Coupon code could not be found"))); - await CleanupUtils.ExecuteCleanupForPaymentProfileProductCustomer(customer, paymentProfile, product, _client); + await CleanupUtils.ExecuteCleanupForPaymentProfileProductCustomer(customer, paymentProfileId, product, _client); await ErrorSuppressionWrapper.RunAsync(async () => { @@ -178,20 +177,17 @@ public async Task CreateSubscription_RestrictedCouponMeteredComponentData_Should var quantityComponent = new QuantityBasedComponent($"widget{randomString}", $"widget {randomString}", PricingScheme.PerUnit, unitPrice: QuantityBasedComponentUnitPrice.FromPrecision(1)); - var restrictedComponentResponse = await _client.ComponentsController.CreateComponentAsync( + var restrictedComponentResponse = await _client.ComponentsController.CreateQuantityBasedComponentAsync( (int)productFamilyId, - ComponentKindPath.QuantityBasedComponents, - CreateComponentBody.FromCreateQuantityBasedComponent( - new CreateQuantityBasedComponent(quantityComponent))); + new CreateQuantityBasedComponent(quantityComponent)); restrictedComponentResponse.Component.Id.Should().NotBeNull(); var meteredComponent = new MeteredComponent($"ApiCalls{randomString}", $"api call {randomString}", PricingScheme.PerUnit, unitPrice: MeteredComponentUnitPrice.FromString("1")); - var componentResponse = await _client.ComponentsController.CreateComponentAsync((int)productFamilyId, - ComponentKindPath.MeteredComponents, - CreateComponentBody.FromCreateMeteredComponent(new CreateMeteredComponent(meteredComponent))); + var componentResponse = await _client.ComponentsController.CreateMeteredComponentAsync((int)productFamilyId, + new CreateMeteredComponent(meteredComponent)); componentResponse.Component.Id.Should().NotBeNull(); @@ -217,7 +213,7 @@ public async Task CreateSubscription_RestrictedCouponMeteredComponentData_Should var customer = await CreationUtils.CreateCustomer(_client); - var paymentProfile = await CreationUtils.CreatePaymentProfile(customer.Customer.Id, _client); + var paymentProfileId = await CreationUtils.CreatePaymentProfile(customer.Customer.Id, _client); var initialBillingDate = DateTime.Now.AddDays(20); @@ -226,7 +222,7 @@ public async Task CreateSubscription_RestrictedCouponMeteredComponentData_Should CustomerId = customer.Customer.Id, ProductId = product.Product.Id, PaymentCollectionMethod = PaymentCollectionMethod.Automatic, - PaymentProfileId = paymentProfile.PaymentProfile.Id, + PaymentProfileId = paymentProfileId, DunningCommunicationDelayEnabled = false, SkipBillingManifestTaxes = false, Components = new List() @@ -245,7 +241,7 @@ await _client.SubscriptionsController.CreateSubscriptionAsync( subscriptionResponse.Subscription.Id.Should().NotBeNull(); subscriptionResponse.Subscription.State.Should().Be(SubscriptionState.AwaitingSignup); - await CleanupUtils.ExecuteBasicSubscriptionCleanup(subscriptionResponse, customer, paymentProfile, product, _client); + await CleanupUtils.ExecuteBasicSubscriptionCleanup(subscriptionResponse, customer, paymentProfileId, product, _client); await ErrorSuppressionWrapper.RunAsync(async () => { @@ -280,14 +276,14 @@ public async Task GetSubscription_WithDefaultData_ShouldSuccess() var customerResponse = await CreationUtils.CreateCustomer(_client); - var paymentProfile = await CreationUtils.CreatePaymentProfile(customerResponse.Customer.Id, _client); + var paymentProfileId = await CreationUtils.CreatePaymentProfile(customerResponse.Customer.Id, _client); var createdSubscription = new CreateSubscription { CustomerId = customerResponse.Customer.Id, ProductId = productResponse.Product.Id, PaymentCollectionMethod = PaymentCollectionMethod.Automatic, - PaymentProfileId = paymentProfile.PaymentProfile.Id, + PaymentProfileId = paymentProfileId, DunningCommunicationDelayEnabled = false, SkipBillingManifestTaxes = false }; @@ -304,7 +300,7 @@ await _client.SubscriptionsController.CreateSubscriptionAsync( subscription.Subscription.Customer.Id.Should().Be(customerResponse.Customer.Id); subscription.Subscription.PaymentCollectionMethod.Should().Be(PaymentCollectionMethod.Automatic); - await CleanupUtils.ExecuteBasicSubscriptionCleanup(subscriptionResponse, customerResponse, paymentProfile, productResponse, _client); + await CleanupUtils.ExecuteBasicSubscriptionCleanup(subscriptionResponse, customerResponse, paymentProfileId, productResponse, _client); } } }