mirror of https://github.com/EasyAbp/EShop.git
15 changed files with 220 additions and 38 deletions
@ -1,10 +1,9 @@ |
|||||
using System; |
using System.Threading.Tasks; |
||||
using System.Threading.Tasks; |
|
||||
|
|
||||
namespace EasyAbp.EShop.Products.Products |
namespace EasyAbp.EShop.Products.Products |
||||
{ |
{ |
||||
public interface IProductPriceProvider |
public interface IProductPriceProvider |
||||
{ |
{ |
||||
Task<decimal> GetPriceAsync(Product product, ProductSku productSku); |
Task<decimal> GetPriceAsync(IProduct product, IProductSku productSku); |
||||
} |
} |
||||
} |
} |
||||
@ -1,13 +1,14 @@ |
|||||
using System; |
using System; |
||||
using System.Linq; |
using System.Linq; |
||||
|
using System.Threading.Tasks; |
||||
using Volo.Abp.Domain.Repositories; |
using Volo.Abp.Domain.Repositories; |
||||
|
|
||||
namespace EasyAbp.EShop.Products.Products |
namespace EasyAbp.EShop.Products.Products |
||||
{ |
{ |
||||
public interface IProductViewRepository : IRepository<ProductView, Guid> |
public interface IProductViewRepository : IRepository<ProductView, Guid> |
||||
{ |
{ |
||||
IQueryable<ProductView> GetQueryable(Guid categoryId); |
Task<IQueryable<ProductView>> GetQueryableAsync(Guid categoryId); |
||||
|
|
||||
IQueryable<ProductView> WithDetails(Guid categoryId); |
Task<IQueryable<ProductView>> WithDetailsAsync(Guid categoryId); |
||||
} |
} |
||||
} |
} |
||||
@ -0,0 +1,46 @@ |
|||||
|
using System; |
||||
|
using System.Linq; |
||||
|
using System.Threading.Tasks; |
||||
|
using EasyAbp.EShop.Products.Products.Dtos; |
||||
|
using Shouldly; |
||||
|
using Xunit; |
||||
|
|
||||
|
namespace EasyAbp.EShop.Products.Products |
||||
|
{ |
||||
|
public class ProductViewAppServiceTests : ProductsApplicationTestBase |
||||
|
{ |
||||
|
private readonly IProductManager _productManager; |
||||
|
private readonly IProductViewAppService _productViewAppService; |
||||
|
|
||||
|
public ProductViewAppServiceTests() |
||||
|
{ |
||||
|
_productManager = GetRequiredService<IProductManager>(); |
||||
|
_productViewAppService = GetRequiredService<IProductViewAppService>(); |
||||
|
} |
||||
|
|
||||
|
[Fact] |
||||
|
public async Task Should_Get_Product_Min_Max_Prices() |
||||
|
{ |
||||
|
var getListResult = await _productViewAppService.GetListAsync(new GetProductListInput |
||||
|
{ |
||||
|
StoreId = ProductsTestData.Store1Id |
||||
|
}); |
||||
|
|
||||
|
getListResult.Items.ShouldNotBeEmpty(); |
||||
|
|
||||
|
var productDto = getListResult.Items.FirstOrDefault(x => x.Id == ProductsTestData.Product1Id); |
||||
|
|
||||
|
productDto.ShouldNotBeNull(); |
||||
|
productDto.MinimumPrice.ShouldBe(1m); |
||||
|
productDto.MaximumPrice.ShouldBe(3m); |
||||
|
|
||||
|
var getResult = await _productViewAppService.GetAsync(ProductsTestData.Product1Id); |
||||
|
|
||||
|
getResult.ShouldNotBeNull(); |
||||
|
getResult.MinimumPrice.ShouldBe(1m); |
||||
|
getResult.MaximumPrice.ShouldBe(3m); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
} |
||||
|
} |
||||
Loading…
Reference in new issue