Skip to content

Commit 3fb5045

Browse files
authored
refactoring and small fix (#108)
1 parent ea7a450 commit 3fb5045

File tree

192 files changed

+2080
-1797
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

192 files changed

+2080
-1797
lines changed

src/Directory.Packages.props

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
<PrivateAssets>all</PrivateAssets>
6060
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
6161
</PackageVersion>
62-
<PackageVersion Include="AspNetCore.HealthChecks.NpgSql" Version="8.0.0" />
62+
<PackageVersion Include="AspNetCore.HealthChecks.NpgSql" Version="9.0.0" />
6363
<PackageVersion Include="AspNetCore.HealthChecks.UI.Client" Version="8.0.0" />
6464
<PackageVersion Include="FluentValidation" Version="12.0.0" />
6565
<PackageVersion Include="FluentValidation.AspNetCore" Version="11.3.0" />
@@ -72,7 +72,7 @@
7272
<PackageVersion Include="MassTransit" Version="8.3.4" />
7373
<PackageVersion Include="MassTransit.RabbitMQ" Version="8.3.4" />
7474
<PackageVersion Include="Microsoft.Data.SqlClient" Version="5.1.4" />
75-
<PackageVersion Include="Microsoft.EntityFrameworkCore" Version="8.0.2" />
75+
<PackageVersion Include="Microsoft.EntityFrameworkCore" Version="9.0.0" />
7676
<PackageVersion Include="Duende.IdentityServer.AspNetIdentity" version="7.2.4" />
7777
<PackageVersion Include="Microsoft.AspNetCore.Authentication.Google" Version="8.0.11" />
7878
<PackageVersion Include="Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore" Version="8.0.11" />

src/Services/Basket/Basket.API.IntegrationTests/ApiFactory.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
using Basket.API.Models;
21
using Marten;
32
using Microsoft.AspNetCore.Hosting;
43
using Microsoft.AspNetCore.Mvc.Testing;

src/Services/Basket/Basket.API.IntegrationTests/Database/Postgres/PostgresDataSeeder.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
using Basket.API.Models;
21
using Marten;
32

43
namespace Basket.API.IntegrationTests.Database.Postgres;

src/Services/Basket/Basket.API.IntegrationTests/Database/Redis/redisDataSeeder.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
using System.Globalization;
2-
using Basket.API.Models;
32
using Google.Protobuf;
43
using Microsoft.Extensions.Caching.Distributed;
54

@@ -60,7 +59,7 @@ private static byte[] GetShoppingCartAsByteArray(ShoppingCart basket)
6059
{
6160
Color = x.Color,
6261
Price = x.Price.ToString(CultureInfo.InvariantCulture),
63-
ProduceId = x.ProductId.ToString(),
62+
ProduceId = x.ProductId?.ToString(),
6463
ProductName = x.ProductName,
6564
Quantity = x.Quantity
6665
}));

src/Services/Basket/Basket.API.IntegrationTests/Features/CheckoutBasket/CheckoutBasketTests.cs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,17 @@ namespace Basket.API.IntegrationTests.Features.CheckoutBasket;
66
[Collection(GetWebApiContainerFactory.Name)]
77
public class CheckoutBasketTests : BaseEndpoint
88
{
9-
private HttpClient _client = default!;
10-
private PostgresDataSeeder _postgresDataSeeder = default!;
11-
private RedisDataSeeder _redisDataSeeder = default!;
12-
private OrderCommandGiven _OrderCommandGiven = default!;
9+
private readonly HttpClient _client;
10+
private readonly PostgresDataSeeder _postgresDataSeeder;
11+
private readonly RedisDataSeeder _redisDataSeeder;
12+
private readonly OrderCommandGiven _orderCommandGiven;
1313

1414
public CheckoutBasketTests(ApiSpecification apiSpecification) : base(apiSpecification)
1515
{
1616
_postgresDataSeeder = _apiSpecification.PostgresDataSeeder;
1717
_redisDataSeeder = _apiSpecification.RedisDataSeeder;
1818
_client = _apiSpecification.HttpClient;
19-
_OrderCommandGiven = _apiSpecification.CreateOrderCommandServerGiven();
19+
_orderCommandGiven = _apiSpecification.CreateOrderCommandServerGiven();
2020
}
2121

2222
[Theory]
@@ -383,7 +383,7 @@ public async Task CheckoutBasket_when_order_command_returns_un_authorized_should
383383
await _postgresDataSeeder.SeedDatabaseAsync(shoppingCart, timeout);
384384
await _redisDataSeeder.AddShoppingCartAsync(shoppingCart, timeout);
385385

386-
_OrderCommandGiven.ReturningUnauthorized();
386+
_orderCommandGiven.ReturningUnauthorized();
387387

388388
// Act
389389
var response = await CallSutAsync(request, timeout);
@@ -416,7 +416,7 @@ public async Task CheckoutBasket_when_order_command_returns_forbidden_should_ret
416416
await _postgresDataSeeder.SeedDatabaseAsync(shoppingCart, timeout);
417417
await _redisDataSeeder.AddShoppingCartAsync(shoppingCart, timeout);
418418

419-
_OrderCommandGiven.ReturningForbidden();
419+
_orderCommandGiven.ReturningForbidden();
420420

421421
// Act
422422
var response = await CallSutAsync(request, timeout);
@@ -450,7 +450,7 @@ public async Task CheckoutBasket_when_order_command_returns_internal_server_erro
450450
await _postgresDataSeeder.SeedDatabaseAsync(shoppingCart, timeout);
451451
await _redisDataSeeder.AddShoppingCartAsync(shoppingCart, timeout);
452452

453-
_OrderCommandGiven.ReturningInternalServerError();
453+
_orderCommandGiven.ReturningInternalServerError();
454454

455455
// Act
456456
var response = await CallSutAsync(request, timeout);
@@ -484,7 +484,7 @@ public async Task CheckoutBasket_when_order_command_returns_bad_request_should_r
484484
await _postgresDataSeeder.SeedDatabaseAsync(shoppingCart, timeout);
485485
await _redisDataSeeder.AddShoppingCartAsync(shoppingCart, timeout);
486486

487-
_OrderCommandGiven.ReturningBadRequest(new ValidationErrors(
487+
_orderCommandGiven.ReturningBadRequest(new ValidationErrors(
488488
[
489489
new ValidationError("order_id", "invalid order id")
490490
]));
@@ -527,7 +527,7 @@ public async Task CheckoutBasket_when_valid_request_should_return_ok_with_order_
527527

528528
await _postgresDataSeeder.SeedDatabaseAsync(shoppingCart, timeout);
529529
await _redisDataSeeder.AddShoppingCartAsync(shoppingCart, timeout);
530-
_OrderCommandGiven.ACreateOrderSuccessResponse(customerId, orderId);
530+
_orderCommandGiven.ACreateOrderSuccessResponse(customerId, orderId);
531531

532532
// Act
533533
var response = await _client
@@ -541,7 +541,7 @@ public async Task CheckoutBasket_when_valid_request_should_return_ok_with_order_
541541
// Assert
542542
response.StatusCode.ShouldBe(HttpStatusCode.OK);
543543
result.ShouldNotBeNull();
544-
result!.OrderId.ShouldBe(orderId);
544+
result.OrderId.ShouldBe(orderId);
545545
}
546546

547547
private async Task<HttpResponseMessage> CallSutAsync(CheckoutBasketRequest request, CancellationToken timeout)

src/Services/Basket/Basket.API.IntegrationTests/Features/DeleteBasket/DeleteBasketTests.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ namespace Basket.API.IntegrationTests.Features.DeleteBasket;
55
[Collection(GetWebApiContainerFactory.Name)]
66
public class DeleteBasketTests : BaseEndpoint
77
{
8-
private HttpClient _client = default!;
9-
private PostgresDataSeeder _postgresDataSeeder = default!;
10-
private RedisDataSeeder _redisDataSeeder = default!;
8+
private HttpClient _client;
9+
private PostgresDataSeeder _postgresDataSeeder;
10+
private RedisDataSeeder _redisDataSeeder;
1111

1212
public DeleteBasketTests(ApiSpecification apiSpecification) : base(apiSpecification)
1313
{

src/Services/Basket/Basket.API.IntegrationTests/Features/GetBasket/GetBasketTests.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ namespace Basket.API.IntegrationTests.Features.GetBasket;
66
[Collection(GetWebApiContainerFactory.Name)]
77
public class GetBasketTests : BaseEndpoint
88
{
9-
private HttpClient _client = default!;
10-
private PostgresDataSeeder _postgresDataSeeder = default!;
11-
private RedisDataSeeder _redisDataSeeder = default!;
9+
private HttpClient _client;
10+
private PostgresDataSeeder _postgresDataSeeder;
11+
private RedisDataSeeder _redisDataSeeder;
1212

1313
public GetBasketTests(ApiSpecification apiSpecification) : base(apiSpecification)
1414
{

src/Services/Basket/Basket.API.IntegrationTests/Features/StoreBasket/StoreBasketTests.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ namespace Basket.API.IntegrationTests.Features.StoreBasket;
88
[Collection(GetWebApiContainerFactory.Name)]
99
public class StoreBasketTests : BaseEndpoint
1010
{
11-
private HttpClient _client = default!;
12-
private DiscountGiven _discountGiven = default!;
13-
private PostgresDataSeeder _postgresDataSeeder = default!;
14-
private RedisDataSeeder _redisDataSeeder = default!;
11+
private HttpClient _client;
12+
private DiscountGiven _discountGiven;
13+
private PostgresDataSeeder _postgresDataSeeder;
14+
private RedisDataSeeder _redisDataSeeder;
1515

1616
public StoreBasketTests(ApiSpecification apiSpecification) : base(apiSpecification)
1717
{
@@ -168,7 +168,7 @@ public async Task StoreBasket_Valid_Request_Saves_Data_In_PostgresDb_And_Redis(S
168168
var resultInPostgresDb =
169169
await _postgresDataSeeder.GetBasketAsync(request.ShoppingCart!.Username, token);
170170
resultInPostgresDb.ShouldNotBeNull();
171-
response.ShoppingCart.Username.ShouldBe(resultInPostgresDb!.Username);
171+
response.ShoppingCart.Username.ShouldBe(resultInPostgresDb.Username);
172172
JsonConvert.SerializeObject(response.ShoppingCart.Items)
173173
.ShouldBe(JsonConvert.SerializeObject(resultInPostgresDb.Items));
174174

@@ -209,7 +209,7 @@ public async Task StoreBasket_Valid_Request_Saves_Data_With_Valid_TotalPrice(Sto
209209
var resultInPostgresDb =
210210
await _postgresDataSeeder.GetBasketAsync(validRequest.ShoppingCart!.Username, token);
211211
resultInPostgresDb.ShouldNotBeNull();
212-
response.ShoppingCart.Username.ShouldBe(resultInPostgresDb!.Username);
212+
response.ShoppingCart.Username.ShouldBe(resultInPostgresDb.Username);
213213
JsonConvert.SerializeObject(response.ShoppingCart.Items)
214214
.ShouldBe(JsonConvert.SerializeObject(resultInPostgresDb.Items));
215215
resultInPostgresDb.TotalPrice.ShouldBe(180);

src/Services/Basket/Basket.API/ApiClient/OrderCommand/DependencyInjectionExtensions.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using Basket.API.ApiClient.AccessToken;
22
using eshop.Shared;
3+
using eshop.Shared.Configurations;
34
using Refit;
45

56
namespace Basket.API.ApiClient.OrderCommand;

src/Services/Basket/Basket.API/ApiClient/OrderCommand/Models.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
namespace Basket.API.ApiClient;
1+
namespace Basket.API.ApiClient.OrderCommand;
22

33
public record CreateOrderRequest
44
{

0 commit comments

Comments
 (0)