Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/Basket.API/GlobalUsings.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
global using System.ComponentModel.DataAnnotations;
global using System.Security.Claims;
global using System.Text.Json;
global using Grpc.Core;
global using Microsoft.AspNetCore.Authorization;
Expand Down
1 change: 0 additions & 1 deletion src/Basket.API/Grpc/BasketService.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System.Diagnostics.CodeAnalysis;
using eShop.Basket.API.Repositories;
using eShop.Basket.API.Extensions;
using eShop.Basket.API.Model;

namespace eShop.Basket.API.Grpc;
Expand Down
1 change: 0 additions & 1 deletion src/Catalog.API/Apis/CatalogApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using System.ComponentModel.DataAnnotations;
using Microsoft.AspNetCore.Http.HttpResults;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Infrastructure;
using Pgvector.EntityFrameworkCore;

namespace eShop.Catalog.API;
Expand Down
2 changes: 0 additions & 2 deletions src/Catalog.API/Infrastructure/CatalogContextSeed.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@ public partial class CatalogContextSeed(
{
public async Task SeedAsync(CatalogContext context)
{
var useCustomizationData = settings.Value.UseCustomizationData;
var contentRootPath = env.ContentRootPath;
var picturePath = env.WebRootPath;

// Workaround from https://github.com/npgsql/efcore.pg/issues/292#issuecomment-388608426
context.Database.OpenConnection();
Expand Down
4 changes: 1 addition & 3 deletions src/Catalog.API/Model/PaginatedItems.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using System.Text.Json.Serialization;

namespace eShop.Catalog.API.Model;
namespace eShop.Catalog.API.Model;

public class PaginatedItems<TEntity>(int pageIndex, int pageSize, long count, IEnumerable<TEntity> data) where TEntity : class
{
Expand Down
2 changes: 0 additions & 2 deletions src/Catalog.API/Services/CatalogAI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,12 @@ public sealed class CatalogAI : ICatalogAI
private readonly IEmbeddingGenerator<string, Embedding<float>>? _embeddingGenerator;

/// <summary>The web host environment.</summary>
private readonly IWebHostEnvironment _environment;
/// <summary>Logger for use in AI operations.</summary>
private readonly ILogger _logger;

public CatalogAI(IWebHostEnvironment environment, ILogger<CatalogAI> logger, IEmbeddingGenerator<string, Embedding<float>>? embeddingGenerator = null)
{
_embeddingGenerator = embeddingGenerator;
_environment = environment;
_logger = logger;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,15 @@ public class CreateOrderCommandHandler
: IRequestHandler<CreateOrderCommand, bool>
{
private readonly IOrderRepository _orderRepository;
private readonly IIdentityService _identityService;
private readonly IMediator _mediator;
private readonly IOrderingIntegrationEventService _orderingIntegrationEventService;
private readonly ILogger<CreateOrderCommandHandler> _logger;

// Using DI to inject infrastructure persistence Repositories
public CreateOrderCommandHandler(IMediator mediator,
IOrderingIntegrationEventService orderingIntegrationEventService,
public CreateOrderCommandHandler(IOrderingIntegrationEventService orderingIntegrationEventService,
IOrderRepository orderRepository,
IIdentityService identityService,
ILogger<CreateOrderCommandHandler> logger)
{
_orderRepository = orderRepository ?? throw new ArgumentNullException(nameof(orderRepository));
_identityService = identityService ?? throw new ArgumentNullException(nameof(identityService));
_mediator = mediator ?? throw new ArgumentNullException(nameof(mediator));
_orderingIntegrationEventService = orderingIntegrationEventService ?? throw new ArgumentNullException(nameof(orderingIntegrationEventService));
_logger = logger ?? throw new ArgumentNullException(nameof(logger));
}
Expand Down
4 changes: 1 addition & 3 deletions src/Ordering.API/GlobalUsings.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
global using Asp.Versioning.Conventions;
global using System.Runtime.Serialization;
global using System.Runtime.Serialization;
global using FluentValidation;
global using MediatR;
global using Microsoft.AspNetCore.Mvc;
Expand All @@ -23,7 +22,6 @@
global using eShop.Ordering.Domain.AggregatesModel.OrderAggregate;
global using eShop.Ordering.Domain.Events;
global using eShop.Ordering.Domain.Exceptions;
global using eShop.Ordering.Domain.SeedWork;
global using eShop.Ordering.Infrastructure;
global using eShop.Ordering.Infrastructure.Idempotency;
global using eShop.Ordering.Infrastructure.Repositories;
Expand Down
3 changes: 1 addition & 2 deletions src/Ordering.Domain/GlobalUsings.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
global using System.Reflection;
global using eShop.Ordering.Domain.Exceptions;
global using eShop.Ordering.Domain.Exceptions;
global using MediatR;
global using eShop.Ordering.Domain.AggregatesModel.BuyerAggregate;
global using eShop.Ordering.Domain.AggregatesModel.OrderAggregate;
Expand Down
1 change: 0 additions & 1 deletion src/Ordering.Infrastructure/GlobalUsings.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
global using System.Data;
global using MediatR;
global using Microsoft.EntityFrameworkCore;
global using Microsoft.EntityFrameworkCore.Design;
global using Microsoft.EntityFrameworkCore.Metadata.Builders;
global using Microsoft.EntityFrameworkCore.Storage;
global using eShop.Ordering.Domain.AggregatesModel.BuyerAggregate;
Expand Down
4 changes: 1 addition & 3 deletions src/WebAppComponents/Services/ICatalogService.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using eShop.WebAppComponents.Catalog;
using eShop.WebAppComponents.Catalog;

namespace eShop.WebAppComponents.Services
{
Expand Down
4 changes: 1 addition & 3 deletions src/WebhookClient/Services/WebhookData.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using System.Text.Json;

namespace eShop.WebhookClient.Services;
namespace eShop.WebhookClient.Services;

public class WebhookData
{
Expand Down
1 change: 0 additions & 1 deletion tests/Basket.UnitTests/GlobalUsings.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
global using System.Collections.Generic;
global using System.Threading.Tasks;
global using Microsoft.AspNetCore.Http;
global using Microsoft.AspNetCore.Mvc;
global using NSubstitute;
global using Microsoft.VisualStudio.TestTools.UnitTesting;
3 changes: 1 addition & 2 deletions tests/Catalog.FunctionalTests/CatalogApiFixture.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.Reflection;
using Microsoft.AspNetCore.Mvc.Testing;
using Microsoft.AspNetCore.Mvc.Testing;

namespace eShop.Catalog.FunctionalTests;

Expand Down
6 changes: 1 addition & 5 deletions tests/Catalog.FunctionalTests/GlobalUsings.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
global using System.IO;
global using System.Net;
global using System.Threading.Tasks;
global using Microsoft.AspNetCore.Hosting;
global using Microsoft.AspNetCore.TestHost;
global using System.Threading.Tasks;
global using Microsoft.Extensions.Configuration;
global using Microsoft.Extensions.Hosting;
global using Xunit;
4 changes: 1 addition & 3 deletions tests/Ordering.FunctionalTests/GlobalUsings.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
global using System.IO;
global using System.Net.Http;
global using System.Net.Http;
global using System.Security.Claims;
global using Microsoft.AspNetCore.Builder;
global using Microsoft.AspNetCore.Hosting;
global using Microsoft.AspNetCore.Http;
global using Microsoft.AspNetCore.TestHost;
global using Microsoft.Extensions.Configuration;
global using Microsoft.Extensions.DependencyInjection;
global using Xunit;
18 changes: 11 additions & 7 deletions tests/Ordering.FunctionalTests/OrderingApiTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,6 @@ public async Task AddNewEmptyOrder()
Headers = { { "x-requestid", Guid.Empty.ToString() } }
};
var response = await _httpClient.PostAsync("api/orders", content);
var s = await response.Content.ReadAsStringAsync();

// Assert
Assert.Equal(HttpStatusCode.BadRequest, response.StatusCode);
Expand All @@ -147,14 +146,12 @@ public async Task AddNewOrder()
PictureUrl = null
};
var cardExpirationDate = Convert.ToDateTime("2023-12-22T12:34:24.334Z");
var OrderRequest = new CreateOrderRequest("1", "TestUser", null, null, null, null, null, "XXXXXXXXXXXX0005", "Test User", cardExpirationDate, "test buyer", 1, null, new List<BasketItem> { item });
var content = new StringContent(JsonSerializer.Serialize(OrderRequest), UTF8Encoding.UTF8, "application/json")
var orderRequest = new CreateOrderRequest("1", "TestUser", null, null, null, null, null, "XXXXXXXXXXXX0005", "Test User", cardExpirationDate, "test buyer", 1, null, new List<BasketItem> { item });
var content = new StringContent(JsonSerializer.Serialize(orderRequest), UTF8Encoding.UTF8, "application/json")
{
Headers = { { "x-requestid", Guid.NewGuid().ToString() } }
};
var response = await _httpClient.PostAsync("api/orders", content);
var s = await response.Content.ReadAsStringAsync();

// Assert
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
}
Expand All @@ -173,16 +170,23 @@ public async Task PostDraftOrder()
Quantity = 1,
PictureUrl = null
};
var bodyContent = new CustomerBasket("1", new List<BasketItem> { item });
var basketItems = new List<BasketItem> { item };
var bodyContent = new CustomerBasket("1", basketItems);
var content = new StringContent(JsonSerializer.Serialize(bodyContent), UTF8Encoding.UTF8, "application/json")
{
Headers = { { "x-requestid", Guid.NewGuid().ToString() } }
};
var response = await _httpClient.PostAsync("api/orders/draft", content);
var s = await response.Content.ReadAsStringAsync();

var responseData = JsonSerializer.Deserialize<OrderDraftDTO>(s, new JsonSerializerOptions() { PropertyNamingPolicy = JsonNamingPolicy.CamelCase });
// Assert
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
Assert.Equal(responseData.OrderItems.Count(), basketItems.Count);
var orderItem = responseData.OrderItems.First();
Assert.Equal(orderItem.ProductId, item.ProductId);
Assert.Equal(orderItem.ProductName, item.ProductName);
Assert.Equal(orderItem.UnitPrice, item.UnitPrice);
Assert.Equal(orderItem.Units, item.Quantity);
}

[Fact]
Expand Down
2 changes: 0 additions & 2 deletions tests/Ordering.UnitTests/GlobalUsings.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
global using MediatR;
global using Microsoft.AspNetCore.Mvc;
global using eShop.Ordering.API.Application.Commands;
global using eShop.Ordering.API.Application.Models;
global using eShop.Ordering.API.Infrastructure.Services;
Expand All @@ -10,5 +9,4 @@
global using eShop.Ordering.Infrastructure.Idempotency;
global using Microsoft.Extensions.Logging;
global using NSubstitute;
global using eShop.Ordering.UnitTests;
global using Microsoft.VisualStudio.TestTools.UnitTesting;