Skip to content

Commit

Permalink
feat: fixes for new version
Browse files Browse the repository at this point in the history
  • Loading branch information
Styx8888 committed Jan 26, 2024
1 parent d294ceb commit 5c141b7
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 32 deletions.
15 changes: 5 additions & 10 deletions Tests/SubscriptionComponentsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down Expand Up @@ -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();

Expand Down
40 changes: 18 additions & 22 deletions Tests/SubscriptionTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
};
Expand All @@ -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]
Expand All @@ -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();

Expand All @@ -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);

Expand All @@ -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<CreateSubscriptionComponent>()
Expand All @@ -122,7 +121,7 @@ await _client.Invoking(c => c.SubscriptionsController.CreateSubscriptionAsync(
.ThrowAsync<ErrorListResponseException>()
.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 () =>
{
Expand Down Expand Up @@ -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();

Expand All @@ -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);

Expand All @@ -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<CreateSubscriptionComponent>()
Expand All @@ -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 () =>
{
Expand Down Expand Up @@ -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
};
Expand All @@ -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);
}
}
}

0 comments on commit 5c141b7

Please sign in to comment.