|
|
@ -1,4 +1,6 @@ |
|
|
using Shentun.Peis.GuideTypes; |
|
|
|
|
|
|
|
|
using Microsoft.EntityFrameworkCore; |
|
|
|
|
|
using Shentun.Peis.GuideTypes; |
|
|
|
|
|
using Shentun.Peis.Models; |
|
|
using Shouldly; |
|
|
using Shouldly; |
|
|
using System; |
|
|
using System; |
|
|
using System.Collections.Generic; |
|
|
using System.Collections.Generic; |
|
|
@ -6,6 +8,8 @@ using System.Linq; |
|
|
using System.Text; |
|
|
using System.Text; |
|
|
using System.Threading.Tasks; |
|
|
using System.Threading.Tasks; |
|
|
using Volo.Abp.Application.Dtos; |
|
|
using Volo.Abp.Application.Dtos; |
|
|
|
|
|
using Volo.Abp.Domain.Repositories; |
|
|
|
|
|
using Volo.Abp.Uow; |
|
|
using Xunit; |
|
|
using Xunit; |
|
|
using Xunit.Abstractions; |
|
|
using Xunit.Abstractions; |
|
|
|
|
|
|
|
|
@ -13,14 +17,56 @@ namespace Shentun.Peis |
|
|
{ |
|
|
{ |
|
|
public class GuideTypeAppServiceTest: PeisApplicationTestBase |
|
|
public class GuideTypeAppServiceTest: PeisApplicationTestBase |
|
|
{ |
|
|
{ |
|
|
|
|
|
private readonly IRepository<GuideType, Guid> _repository; |
|
|
private readonly GuideTypeAppService _guideTypeAppService; |
|
|
private readonly GuideTypeAppService _guideTypeAppService; |
|
|
private readonly ITestOutputHelper _testOutputHelper; |
|
|
|
|
|
|
|
|
private readonly ITestOutputHelper _output; |
|
|
|
|
|
private readonly IUnitOfWorkManager _unitOfWorkManager; |
|
|
public GuideTypeAppServiceTest(ITestOutputHelper testOutputHelper) |
|
|
public GuideTypeAppServiceTest(ITestOutputHelper testOutputHelper) |
|
|
{ |
|
|
{ |
|
|
_testOutputHelper = testOutputHelper; |
|
|
|
|
|
|
|
|
_output = testOutputHelper; |
|
|
|
|
|
_unitOfWorkManager = GetRequiredService<IUnitOfWorkManager>(); |
|
|
|
|
|
_repository = GetRequiredService<IRepository<GuideType, Guid>>(); |
|
|
_guideTypeAppService = GetRequiredService<GuideTypeAppService>(); |
|
|
_guideTypeAppService = GetRequiredService<GuideTypeAppService>(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
[Fact] |
|
|
|
|
|
public async Task GetQueryListAsync() |
|
|
|
|
|
{ |
|
|
|
|
|
using (var uow = _unitOfWorkManager.Begin()) |
|
|
|
|
|
{ |
|
|
|
|
|
IQueryable<GuideType> queryable = await _repository.GetQueryableAsync(); |
|
|
|
|
|
var itemTypes = (from item in queryable |
|
|
|
|
|
|
|
|
|
|
|
select item).ToList(); |
|
|
|
|
|
foreach (var item in itemTypes) |
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
|
|
|
_output.WriteLine(item.DisplayName); |
|
|
|
|
|
} |
|
|
|
|
|
await uow.CompleteAsync(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
[Fact] |
|
|
|
|
|
public async Task GetListAsync() |
|
|
|
|
|
{ |
|
|
|
|
|
PagedAndSortedResultRequestDto qc = new PagedAndSortedResultRequestDto() |
|
|
|
|
|
{ |
|
|
|
|
|
Sorting = "displayorder" |
|
|
|
|
|
}; |
|
|
|
|
|
var result = await _guideTypeAppService.GetListAsync(qc); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_output.WriteLine(result.TotalCount.ToString()); |
|
|
|
|
|
foreach (var item in result.Items) |
|
|
|
|
|
{ |
|
|
|
|
|
Console.WriteLine(item.DisplayName); |
|
|
|
|
|
_output.WriteLine(item.DisplayName); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
[Fact] |
|
|
[Fact] |
|
|
public async Task GetList() |
|
|
public async Task GetList() |
|
|
{ |
|
|
{ |
|
|
@ -29,11 +75,11 @@ namespace Shentun.Peis |
|
|
var result = await _guideTypeAppService.GetListAsync(qc); |
|
|
var result = await _guideTypeAppService.GetListAsync(qc); |
|
|
result.TotalCount.ShouldBeGreaterThanOrEqualTo(4); |
|
|
result.TotalCount.ShouldBeGreaterThanOrEqualTo(4); |
|
|
Console.WriteLine(result.TotalCount); |
|
|
Console.WriteLine(result.TotalCount); |
|
|
_testOutputHelper.WriteLine(result.TotalCount.ToString()); |
|
|
|
|
|
|
|
|
_output.WriteLine(result.TotalCount.ToString()); |
|
|
foreach (var item in result.Items) |
|
|
foreach (var item in result.Items) |
|
|
{ |
|
|
{ |
|
|
Console.WriteLine(item.DisplayName); |
|
|
Console.WriteLine(item.DisplayName); |
|
|
_testOutputHelper.WriteLine(item.DisplayName); |
|
|
|
|
|
|
|
|
_output.WriteLine(item.DisplayName); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
@ -46,10 +92,28 @@ namespace Shentun.Peis |
|
|
{ |
|
|
{ |
|
|
DisplayName = "Foo", |
|
|
DisplayName = "Foo", |
|
|
}); |
|
|
}); |
|
|
_testOutputHelper.WriteLine(result.Id.ToString()); |
|
|
|
|
|
|
|
|
_output.WriteLine(result.Id.ToString()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
[Fact] |
|
|
|
|
|
public async Task DeleteAsync() |
|
|
|
|
|
{ |
|
|
|
|
|
try |
|
|
|
|
|
{ |
|
|
|
|
|
using (var uow = _unitOfWorkManager.Begin()) |
|
|
|
|
|
{ |
|
|
|
|
|
await _guideTypeAppService.DeleteAsync(new Guid("3a0d6dfb-300b-fe76-15b6-f0398bee2f50")); |
|
|
|
|
|
_output.WriteLine("删除成功"); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
catch (Exception ex) |
|
|
|
|
|
{ |
|
|
|
|
|
_output.WriteLine(ex.Message); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |