mirror of
https://github.com/bitwarden/server.git
synced 2025-07-12 21:27:35 -05:00

* 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
42 lines
1.1 KiB
C#
42 lines
1.1 KiB
C#
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);
|
|
}
|
|
}
|