mirror of
https://github.com/bitwarden/server
synced 2025-12-31 15:43:16 +00:00
[PM-21881] Manage payment details outside of checkout (#6032)
* Add feature flag * Further establish billing command pattern and use in PreviewTaxAmountCommand * Add billing address models/commands/queries/tests * Update TypeReadingJsonConverter to account for new union types * Add payment method models/commands/queries/tests * Add credit models/commands/queries/tests * Add command/query registrations * Add new endpoints to support new command model and payment functionality * Run dotnet format * Add InjectUserAttribute for easier AccountBillilngVNextController handling * Add InjectOrganizationAttribute for easier OrganizationBillingVNextController handling * Add InjectProviderAttribute for easier ProviderBillingVNextController handling * Add XML documentation for billing command pipeline * Fix StripeConstants post-nullability * More nullability cleanup * Run dotnet format
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
using Bit.Core.Billing.Payment.Queries;
|
||||
using Bit.Core.Billing.Services;
|
||||
using Bit.Core.Entities;
|
||||
using NSubstitute;
|
||||
using NSubstitute.ReturnsExtensions;
|
||||
using Stripe;
|
||||
using Xunit;
|
||||
|
||||
namespace Bit.Core.Test.Billing.Payment.Queries;
|
||||
|
||||
public class GetCreditQueryTests
|
||||
{
|
||||
private readonly ISubscriberService _subscriberService = Substitute.For<ISubscriberService>();
|
||||
private readonly GetCreditQuery _query;
|
||||
|
||||
public GetCreditQueryTests()
|
||||
{
|
||||
_query = new GetCreditQuery(_subscriberService);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Run_NoCustomer_ReturnsNull()
|
||||
{
|
||||
_subscriberService.GetCustomer(Arg.Any<ISubscriber>()).ReturnsNull();
|
||||
|
||||
var credit = await _query.Run(Substitute.For<ISubscriber>());
|
||||
|
||||
Assert.Null(credit);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Run_ReturnsCredit()
|
||||
{
|
||||
_subscriberService.GetCustomer(Arg.Any<ISubscriber>()).Returns(new Customer { Balance = -1000 });
|
||||
|
||||
var credit = await _query.Run(Substitute.For<ISubscriber>());
|
||||
|
||||
Assert.NotNull(credit);
|
||||
Assert.Equal(10M, credit);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user