|
|
@ -8,7 +8,9 @@ using EasyAbp.EShop.Products.ProductDetails; |
|
|
using EasyAbp.EShop.Products.Products.Dtos; |
|
|
using EasyAbp.EShop.Products.Products.Dtos; |
|
|
using Microsoft.EntityFrameworkCore; |
|
|
using Microsoft.EntityFrameworkCore; |
|
|
using Microsoft.Extensions.Options; |
|
|
using Microsoft.Extensions.Options; |
|
|
|
|
|
using Volo.Abp.Data; |
|
|
using Volo.Abp.Domain.Entities; |
|
|
using Volo.Abp.Domain.Entities; |
|
|
|
|
|
using Volo.Abp.ObjectExtending; |
|
|
using Xunit; |
|
|
using Xunit; |
|
|
|
|
|
|
|
|
namespace EasyAbp.EShop.Products.Products |
|
|
namespace EasyAbp.EShop.Products.Products |
|
|
@ -47,14 +49,14 @@ namespace EasyAbp.EShop.Products.Products |
|
|
IsPublished = true, |
|
|
IsPublished = true, |
|
|
ProductAttributes = new List<CreateUpdateProductAttributeDto> |
|
|
ProductAttributes = new List<CreateUpdateProductAttributeDto> |
|
|
{ |
|
|
{ |
|
|
new CreateUpdateProductAttributeDto |
|
|
new() |
|
|
{ |
|
|
{ |
|
|
DisplayName = "Default Attribute 1", |
|
|
DisplayName = "Default Attribute 1", |
|
|
Description = "Default Description 1", |
|
|
Description = "Default Description 1", |
|
|
DisplayOrder = 1, |
|
|
DisplayOrder = 1, |
|
|
ProductAttributeOptions = new List<CreateUpdateProductAttributeOptionDto> |
|
|
ProductAttributeOptions = new List<CreateUpdateProductAttributeOptionDto> |
|
|
{ |
|
|
{ |
|
|
new CreateUpdateProductAttributeOptionDto |
|
|
new() |
|
|
{ |
|
|
{ |
|
|
DisplayName = "Option 1" |
|
|
DisplayName = "Option 1" |
|
|
} |
|
|
} |
|
|
@ -63,6 +65,13 @@ namespace EasyAbp.EShop.Products.Products |
|
|
} |
|
|
} |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
ObjectExtensionManager.Instance.AddOrUpdate(new[] |
|
|
|
|
|
{ |
|
|
|
|
|
typeof(CreateUpdateProductDto), typeof(ProductDto), typeof(Product) |
|
|
|
|
|
}, config => { config.AddOrUpdateProperty<string>("MyExtraProperty"); }); |
|
|
|
|
|
|
|
|
|
|
|
requestDto.SetProperty("MyExtraProperty", "1234"); |
|
|
|
|
|
|
|
|
// Act
|
|
|
// Act
|
|
|
var response = await _productAppService.CreateAsync(requestDto); |
|
|
var response = await _productAppService.CreateAsync(requestDto); |
|
|
|
|
|
|
|
|
@ -71,6 +80,7 @@ namespace EasyAbp.EShop.Products.Products |
|
|
response.IsPublished.ShouldBe(true); |
|
|
response.IsPublished.ShouldBe(true); |
|
|
response.DisplayName.ShouldBe("Pencil"); |
|
|
response.DisplayName.ShouldBe("Pencil"); |
|
|
response.UniqueName.ShouldBe("Unique Pencil"); |
|
|
response.UniqueName.ShouldBe("Unique Pencil"); |
|
|
|
|
|
response.GetProperty<string>("MyExtraProperty").ShouldBe("1234"); |
|
|
|
|
|
|
|
|
UsingDbContext(db => |
|
|
UsingDbContext(db => |
|
|
{ |
|
|
{ |
|
|
@ -102,14 +112,22 @@ namespace EasyAbp.EShop.Products.Products |
|
|
productAttributeOptionId = productAttribute.ProductAttributeOptions.First().Id; |
|
|
productAttributeOptionId = productAttribute.ProductAttributeOptions.First().Id; |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
var response = await _productAppService.CreateSkuAsync(productId, new CreateProductSkuDto |
|
|
var requestDto = new CreateProductSkuDto |
|
|
{ |
|
|
{ |
|
|
AttributeOptionIds = new List<Guid> {productAttributeOptionId}, |
|
|
AttributeOptionIds = new List<Guid> { productAttributeOptionId }, |
|
|
Currency = "USD", |
|
|
Currency = "USD", |
|
|
Price = 1m, |
|
|
Price = 1m, |
|
|
OrderMinQuantity = 1, |
|
|
OrderMinQuantity = 1, |
|
|
OrderMaxQuantity = 10 |
|
|
OrderMaxQuantity = 10 |
|
|
}); |
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
ObjectExtensionManager.Instance.AddOrUpdate(new[] |
|
|
|
|
|
{ |
|
|
|
|
|
typeof(CreateProductSkuDto), typeof(ProductSkuDto), typeof(ProductSku) |
|
|
|
|
|
}, config => { config.AddOrUpdateProperty<string>("MyExtraProperty"); }); |
|
|
|
|
|
|
|
|
|
|
|
requestDto.SetProperty("MyExtraProperty", "1234"); |
|
|
|
|
|
var response = await _productAppService.CreateSkuAsync(productId, requestDto); |
|
|
|
|
|
|
|
|
response.ShouldNotBeNull(); |
|
|
response.ShouldNotBeNull(); |
|
|
response.MinimumPrice.ShouldBe(1m); |
|
|
response.MinimumPrice.ShouldBe(1m); |
|
|
@ -123,6 +141,7 @@ namespace EasyAbp.EShop.Products.Products |
|
|
responseSku.AttributeOptionIds.First().ShouldBe(productAttributeOptionId); |
|
|
responseSku.AttributeOptionIds.First().ShouldBe(productAttributeOptionId); |
|
|
responseSku.OrderMinQuantity.ShouldBe(1); |
|
|
responseSku.OrderMinQuantity.ShouldBe(1); |
|
|
responseSku.OrderMaxQuantity.ShouldBe(10); |
|
|
responseSku.OrderMaxQuantity.ShouldBe(10); |
|
|
|
|
|
responseSku.GetProperty("MyExtraProperty", "1234"); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
[Fact] |
|
|
[Fact] |
|
|
|