diff --git a/test/Core.Test/Billing/Services/SubscriberServiceTests.cs b/test/Core.Test/Billing/Services/SubscriberServiceTests.cs index 94dc85aa01..92917240c6 100644 --- a/test/Core.Test/Billing/Services/SubscriberServiceTests.cs +++ b/test/Core.Test/Billing/Services/SubscriberServiceTests.cs @@ -3,10 +3,13 @@ using Bit.Core.AdminConsole.Entities.Provider; using Bit.Core.Billing.Caches; using Bit.Core.Billing.Constants; using Bit.Core.Billing.Models; +using Bit.Core.Billing.Services; +using Bit.Core.Billing.Services.Contracts; using Bit.Core.Billing.Services.Implementations; using Bit.Core.Enums; using Bit.Core.Services; using Bit.Core.Settings; +using Bit.Core.Test.Billing.Stubs; using Bit.Test.Common.AutoFixture; using Bit.Test.Common.AutoFixture.Attributes; using Braintree; @@ -1586,6 +1589,12 @@ public class SubscriberServiceTests TaxIds = new StripeList { Data = [new TaxId { Id = "tax_id_1", Type = "us_ein" }] } }); + var subscription = new Subscription { Items = new StripeList() }; + sutProvider.GetDependency().SubscriptionGetAsync(Arg.Any()) + .Returns(subscription); + sutProvider.GetDependency().CreateAsync(Arg.Any()) + .Returns(new FakeAutomaticTaxStrategy(true)); + await sutProvider.Sut.UpdateTaxInformation(provider, taxInformation); await stripeAdapter.Received(1).CustomerUpdateAsync(provider.GatewayCustomerId, Arg.Is( diff --git a/test/Core.Test/Billing/Stubs/FakeAutomaticTaxStrategy.cs b/test/Core.Test/Billing/Stubs/FakeAutomaticTaxStrategy.cs new file mode 100644 index 0000000000..01a316df7d --- /dev/null +++ b/test/Core.Test/Billing/Stubs/FakeAutomaticTaxStrategy.cs @@ -0,0 +1,29 @@ +using Bit.Core.Billing.Services; +using Stripe; + +namespace Bit.Core.Test.Billing.Stubs; + +/// +/// Whether the subscription options will have automatic tax enabled or not. +/// +public class FakeAutomaticTaxStrategy( + bool IsAutomaticTaxEnabled) : IAutomaticTaxStrategy +{ + public SubscriptionUpdateOptions? GetUpdateOptions(Subscription subscription) + { + return new SubscriptionUpdateOptions + { + AutomaticTax = new SubscriptionAutomaticTaxOptions { Enabled = IsAutomaticTaxEnabled } + }; + } + + public void SetCreateOptions(SubscriptionCreateOptions options, Customer customer) + { + options.AutomaticTax = new SubscriptionAutomaticTaxOptions { Enabled = IsAutomaticTaxEnabled }; + } + + public void SetUpdateOptions(SubscriptionUpdateOptions options, Subscription subscription) + { + options.AutomaticTax = new SubscriptionAutomaticTaxOptions { Enabled = IsAutomaticTaxEnabled }; + } +}