Skip to content

Commit ec7f170

Browse files
committed
refactor: reorganize namespaces
1 parent 0f2729f commit ec7f170

File tree

11 files changed

+493
-7
lines changed

11 files changed

+493
-7
lines changed

Tests/UnitTests/Ecommerce.Api.UnitTests/Services/UserContextServiceTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
using Microsoft.AspNetCore.Http;
77
using Moq;
88

9-
namespace Ecommerce.UnitTests.Ecommerce.Api.UnitTests.Services;
9+
namespace Ecommerce.UnitTests.Api.Services;
1010

1111
public class UserContextServiceTests
1212
{

Tests/UnitTests/Ecommerce.Application.UnitTests/UseCases/Products/Commands/CreateProduct/CreateProductCommandHandlerTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
using Ecommerce.Domain.ProductAggregate.ValueObjects;
2424
using Ecommerce.Domain.UserAggregate;
2525
using Ecommerce.Domain.UserAggregate.ValueObjects;
26-
using Ecommerce.UnitTests.Ecommerce.Application.UnitTests.UseCases;
26+
using Ecommerce.UnitTests;
2727
using FluentAssertions;
2828
using FluentResults;
2929
using MediatR;

Tests/UnitTests/Ecommerce.Application.UnitTests/UseCases/Users/Commands/RegisterUser/RegisterUserCommandHandlerTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@
77
using Ecommerce.Domain.Common.ValueObjects;
88
using Ecommerce.Domain.UserAggregate;
99
using Ecommerce.Domain.UserAggregate.ValueObjects;
10-
using Ecommerce.UnitTests.Ecommerce.Application.UnitTests.UseCases;
10+
using Ecommerce.UnitTests;
1111
using FluentAssertions;
1212
using FluentResults;
1313
using Microsoft.AspNetCore.Identity;
1414
using Moq;
1515

16-
namespace Ecommerce.Application.UnitTests.UseCases.Users.Commands.RegisterUser;
16+
namespace Ecommerce.UnitTests.Application.UseCases.Users.Commands.RegisterUser;
1717

1818
public class RegisterUserCommandHandlerTests
1919
{

Tests/UnitTests/Ecommerce.Application.UnitTests/UseCases/Users/Commands/WishlistProducts/WishlistProductsCommandHandlerTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
using FluentResults;
99
using Moq;
1010

11-
namespace Ecommerce.UnitTests.Ecommerce.Application.UnitTests.UseCases.Users.Commands.WishlistProducts;
11+
namespace Ecommerce.UnitTests.Application.UseCases.Users.Commands.WishlistProducts;
1212

1313
public class WishlistProductsCommandHandlerTests
1414
{

Tests/UnitTests/Ecommerce.Application.UnitTests/UseCases/Users/Queries/GetCart/GetCartQueryHandlerTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
using FluentResults;
1111
using Moq;
1212

13-
namespace Ecommerce.UnitTests.Ecommerce.Application.UnitTests.UseCases.Users.Queries.GetCart;
13+
namespace Ecommerce.UnitTests.Application.UseCases.Users.Queries.GetCart;
1414

1515
public class GetCartQueryHandlerTests
1616
{

Tests/UnitTests/Ecommerce.Application.UnitTests/UseCases/Users/Queries/LoginUser/LoginUserQueryHandlerTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
using Ecommerce.Domain.Common.ValueObjects;
1010
using Ecommerce.Domain.UserAggregate;
1111
using Ecommerce.Domain.UserAggregate.ValueObjects;
12-
using Ecommerce.UnitTests.Ecommerce.Application.UnitTests.UseCases;
12+
using Ecommerce.UnitTests;
1313
using FluentAssertions;
1414
using FluentResults;
1515
using Microsoft.AspNetCore.Identity;
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
using Ecommerce.Application.UseCases.Products.Common;
2+
using Ecommerce.Application.UseCases.Users.Queries.GetCartItems;
3+
using Ecommerce.Domain.ProductAggregate.ValueObjects;
4+
5+
namespace Ecommerce.UnitTests;
6+
7+
public partial class Utils
8+
{
9+
public record Cart
10+
{
11+
public const int PageNumber = 1;
12+
public const int PageSize = 10;
13+
14+
public static GetCartQuery CreateGetCartQuery()
15+
{
16+
return new GetCartQuery(PageNumber, PageSize);
17+
}
18+
19+
public static CartResult CreateCartResult(int i = 1)
20+
{
21+
var cartItemResults = CartItem.CreateCartItemResults(i);
22+
var totalPrice = cartItemResults.Sum(x => x.Product.PriceValue * x.Quantity);
23+
return new CartResult
24+
{
25+
Items = CartItem.CreateCartItemResults(i),
26+
TotalItems = i,
27+
TotalPrice = totalPrice,
28+
};
29+
}
30+
31+
public record CartItem
32+
{
33+
public const int Quantity = 10;
34+
public static readonly ProductId ProductId = ProductId.CreateUnique();
35+
36+
public static Ecommerce.Domain.UserAggregate.Entities.CartItem Create()
37+
{
38+
return Ecommerce.Domain.UserAggregate.Entities.CartItem.Create(
39+
Utils.Cart.CartItem.ProductId,
40+
Utils.Cart.CartItem.Quantity
41+
);
42+
}
43+
44+
public static List<Ecommerce.Domain.UserAggregate.Entities.CartItem> CreateCartItems(
45+
int i = 1
46+
)
47+
{
48+
return Enumerable.Range(1, i).Select(_ => Create()).ToList();
49+
}
50+
51+
public static List<CartItemResult> CreateCartItemResults(int i = 1)
52+
{
53+
return Enumerable
54+
.Range(1, i)
55+
.Select(_ => new CartItemResult
56+
{
57+
Id = Utils.Cart.CartItem.ProductId.Value.ToString(),
58+
Quantity = Utils.Cart.CartItem.Quantity,
59+
Product = Utils.Product.CreateProductResult(Utils.Product.CreateProduct()),
60+
})
61+
.ToList();
62+
}
63+
}
64+
}
65+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
using System.Text;
2+
3+
namespace Ecommerce.UnitTests;
4+
5+
public partial class Utils
6+
{
7+
public record Image
8+
{
9+
public const string ImageData = "ImageData";
10+
public static readonly Stream ImageStream = new MemoryStream(Encoding.UTF8.GetBytes(ImageData));
11+
public static long ImageSize => ImageStream.Length;
12+
13+
public static readonly string FileName = nameof(FileName);
14+
public static readonly string LeftImageFileName = nameof(LeftImageFileName);
15+
public static readonly string RightImageFileName = nameof(RightImageFileName);
16+
public static readonly string TopImageFileName = nameof(TopImageFileName);
17+
public static readonly string BackImageFileName = nameof(BackImageFileName);
18+
public static readonly string FrontImageFileName = nameof(FrontImageFileName);
19+
public static readonly string BottomImageFileName = nameof(BottomImageFileName);
20+
21+
public static string ImageDataFromIndex(int i) => $"{ImageData} {i}";
22+
23+
public static Stream ImageStreamFromIndex(int i) =>
24+
new MemoryStream(Encoding.UTF8.GetBytes(ImageDataFromIndex(i)));
25+
26+
public static long ImageSizeFromIndex(int i) => ImageStreamFromIndex(i).Length;
27+
28+
public static string FileNameFromIndex(int i) => $"{FileName} {i}";
29+
30+
public static string LeftImageFileNameFromIndex(int i) => $"{LeftImageFileName} {i}";
31+
32+
public static string RightImageFileNameFromIndex(int i) => $"{RightImageFileName} {i}";
33+
34+
public static string TopImageFileNameFromIndex(int i) => $"{TopImageFileName} {i}";
35+
36+
public static string BackImageFileNameFromIndex(int i) => $"{BackImageFileName} {i}";
37+
38+
public static string FrontImageFileNameFromIndex(int i) => $"{FrontImageFileName} {i}";
39+
40+
public static string BottomImageFileNameFromIndex(int i) => $"{BottomImageFileName} {i}";
41+
}
42+
}

0 commit comments

Comments
 (0)