mirror of https://github.com/EasyAbp/EShop.git
5 changed files with 106 additions and 4 deletions
@ -1,10 +1,19 @@ |
|||
namespace EasyAbp.EShop.Products |
|||
using System; |
|||
using EasyAbp.EShop.Products.EntityFrameworkCore; |
|||
|
|||
namespace EasyAbp.EShop.Products |
|||
{ |
|||
/* Inherit from this class for your application layer tests. |
|||
* See SampleAppService_Tests for example. |
|||
*/ |
|||
public abstract class ProductsApplicationTestBase : ProductsTestBase<EShopProductsApplicationTestModule> |
|||
{ |
|||
|
|||
protected void UsingDbContext(Action<IProductsDbContext> action) |
|||
{ |
|||
using (var dbContext = GetRequiredService<IProductsDbContext>()) |
|||
{ |
|||
action.Invoke(dbContext); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,11 @@ |
|||
using System; |
|||
|
|||
namespace EasyAbp.EShop.Products |
|||
{ |
|||
public class ProductsTestData |
|||
{ |
|||
public static Guid Store1Id { get; } = Guid.NewGuid(); |
|||
|
|||
public static Guid ProductDetails1Id { get; } = Guid.NewGuid(); |
|||
} |
|||
} |
|||
@ -0,0 +1,27 @@ |
|||
using System.Threading.Tasks; |
|||
using EasyAbp.EShop.Products.ProductDetails; |
|||
using Volo.Abp.DependencyInjection; |
|||
using Volo.Abp.Threading; |
|||
|
|||
namespace EasyAbp.EShop.Products |
|||
{ |
|||
public class ProductsTestDataBuilder : ITransientDependency |
|||
{ |
|||
private readonly IProductDetailRepository _productDetailRepository; |
|||
|
|||
public ProductsTestDataBuilder(IProductDetailRepository productDetailRepository) |
|||
{ |
|||
_productDetailRepository = productDetailRepository; |
|||
} |
|||
|
|||
public void Build() |
|||
{ |
|||
AsyncHelper.RunSync(BuildAsync); |
|||
} |
|||
|
|||
public async Task BuildAsync() |
|||
{ |
|||
await _productDetailRepository.InsertAsync(new ProductDetail(ProductsTestData.ProductDetails1Id, "Product Details")); |
|||
} |
|||
} |
|||
} |
|||
Loading…
Reference in new issue