Skip to content

Commit ef7c112

Browse files
committed
Mock pricingClient in api tests
1 parent 5ec80e5 commit ef7c112

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

test/Api.IntegrationTest/AdminConsole/Controllers/OrganizationsControllerTests.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,11 @@
55
using Bit.Core.AdminConsole.Entities;
66
using Bit.Core.AdminConsole.Enums.Provider;
77
using Bit.Core.Billing.Enums;
8+
using Bit.Core.Billing.Pricing;
89
using Bit.Core.Enums;
910
using Bit.Core.Repositories;
11+
using Bit.Core.Test.Billing.Mocks;
12+
using NSubstitute;
1013
using Xunit;
1114

1215
namespace Bit.Api.IntegrationTest.AdminConsole.Controllers;
@@ -25,6 +28,15 @@ public class OrganizationsControllerTests : IClassFixture<ApiApplicationFactory>
2528
public OrganizationsControllerTests(ApiApplicationFactory apiFactory)
2629
{
2730
_factory = apiFactory;
31+
_factory.SubstituteService<IPricingClient>(pricingClient =>
32+
{
33+
pricingClient
34+
.GetPlan(Arg.Any<PlanType>())
35+
.Returns(x => MockPlans.Get(x.Arg<PlanType>()));
36+
pricingClient
37+
.GetPlanOrThrow(Arg.Any<PlanType>())
38+
.Returns(x => MockPlans.Get(x.Arg<PlanType>()));
39+
});
2840
_client = _factory.CreateClient();
2941
_loginHelper = new LoginHelper(_factory, _client);
3042
}

test/Api.IntegrationTest/Api.IntegrationTest.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
<ItemGroup>
2020
<ProjectReference Include="..\..\src\Api\Api.csproj" />
2121
<ProjectReference Include="..\..\util\Seeder\Seeder.csproj" />
22+
<ProjectReference Include="..\Core.Test\Core.Test.csproj" />
2223
<ProjectReference Include="..\IntegrationTestCommon\IntegrationTestCommon.csproj" />
2324

2425
<Content Include="..\..\src\Api\appsettings.*.json">

0 commit comments

Comments
 (0)