csharp-abp-study/Skcks.Study.AbpProject/test/Skcks.Study.AbpProject.Application.Tests/Products/ProductAppServiceTests.cs
2024-11-22 22:33:59 +08:00

47 lines
1.4 KiB
C#

using Shouldly;
using System.Threading.Tasks;
using Skcks.Study.AbpProject.Products;
using Volo.Abp.Application.Dtos;
using Volo.Abp.Identity;
using Volo.Abp.Modularity;
using Xunit;
namespace Skcks.Study.AbpProject.Products;
/* This is just an example test class.
* Normally, you don't test code of the modules you are using
* (like IIdentityUserAppService here).
* Only test your own application services.
*/
public abstract class ProductAppService<TStartupModule> : AbpProjectApplicationTestBase<TStartupModule>
where TStartupModule : IAbpModule
{
private readonly IIdentityUserAppService _userAppService;
private readonly IProductAppService _productAppService;
protected ProductAppService()
{
_userAppService = GetRequiredService<IIdentityUserAppService>();
_productAppService = GetRequiredService<IProductAppService>();
}
[Fact]
public async Task Initial_Data_Should_Contain_Admin_User()
{
//Act
var result = await _userAppService.GetListAsync(new GetIdentityUsersInput());
//Assert
result.TotalCount.ShouldBeGreaterThan(0);
result.Items.ShouldContain(u => u.UserName == "admin");
}
[Fact]
public async Task TestProduct()
{
var result = await _productAppService.GetListAsync(new PagedAndSortedResultRequestDto());
result.TotalCount.ShouldBeGreaterThan(0);
// _output.WriteLine(resultDto.ToString());
}
}