Browse Source

完成数据字典模块

pull/6/head
WangJunZzz 5 years ago
parent
commit
a1fd94dc7f
  1. 6
      aspnet-core/modules/DataDictionaryManagement/src/CompanyName.ProjectName.DataDictionaryManagement.Application/DataDictionaries/DataDictionaryAppService.cs
  2. 2
      aspnet-core/modules/DataDictionaryManagement/src/CompanyName.ProjectName.DataDictionaryManagement.Domain/DataDictionaries/Aggregates/DataDictionary.cs
  3. 2
      aspnet-core/modules/DataDictionaryManagement/src/CompanyName.ProjectName.DataDictionaryManagement.Domain/DataDictionaries/Aggregates/DataDictionaryDetail.cs
  4. 75
      aspnet-core/modules/DataDictionaryManagement/test/CompanyName.ProjectName.DataDictionaryManagement.Application.Tests/DataDictionaries/DataDictionaryAppService_Tests.cs

6
aspnet-core/modules/DataDictionaryManagement/src/CompanyName.ProjectName.DataDictionaryManagement.Application/DataDictionaries/DataDictionaryAppService.cs

@ -18,9 +18,11 @@ namespace CompanyName.ProjectName.DataDictionaryManagement.DataDictionaries
/// 如果是其他的操作全部通过对应manger进行操作 /// 如果是其他的操作全部通过对应manger进行操作
/// </summary> /// </summary>
private readonly IDataDictionaryRepository _dataDictionaryRepository; private readonly IDataDictionaryRepository _dataDictionaryRepository;
private readonly DataDictionaryManager _dataDictionaryManager; private readonly DataDictionaryManager _dataDictionaryManager;
public DataDictionaryAppService(IDataDictionaryRepository dataDictionaryRepository, DataDictionaryManager dataDictionaryManager)
public DataDictionaryAppService(
IDataDictionaryRepository dataDictionaryRepository,
DataDictionaryManager dataDictionaryManager)
{ {
_dataDictionaryRepository = dataDictionaryRepository; _dataDictionaryRepository = dataDictionaryRepository;
_dataDictionaryManager = dataDictionaryManager; _dataDictionaryManager = dataDictionaryManager;

2
aspnet-core/modules/DataDictionaryManagement/src/CompanyName.ProjectName.DataDictionaryManagement.Domain/DataDictionaries/Aggregates/DataDictionary.cs

@ -90,7 +90,7 @@ namespace CompanyName.ProjectName.DataDictionaryManagement.DataDictionaries.Aggr
private void SetDescription(string description) private void SetDescription(string description)
{ {
Guard.Length(description, nameof(description), DataDictionaryMaxLengths.Description); Guard.Length(description, nameof(description), DataDictionaryMaxLengths.Description);
Description = description; Description = description ?? string.Empty;
} }
public void AddDetail(Guid dataDictionayDetailId, string code, string displayText, int order = 1, public void AddDetail(Guid dataDictionayDetailId, string code, string displayText, int order = 1,

2
aspnet-core/modules/DataDictionaryManagement/src/CompanyName.ProjectName.DataDictionaryManagement.Domain/DataDictionaries/Aggregates/DataDictionaryDetail.cs

@ -86,7 +86,7 @@ namespace CompanyName.ProjectName.DataDictionaryManagement.DataDictionaries.Aggr
public void SetDescription(string description) public void SetDescription(string description)
{ {
Guard.Length(description, nameof(description), DataDictionaryMaxLengths.Description); Guard.Length(description, nameof(description), DataDictionaryMaxLengths.Description);
Description = description; Description = Description = description ?? string.Empty;
} }
} }
} }

75
aspnet-core/modules/DataDictionaryManagement/test/CompanyName.ProjectName.DataDictionaryManagement.Application.Tests/DataDictionaries/DataDictionaryAppService_Tests.cs

@ -0,0 +1,75 @@
using System.Linq;
using System.Threading.Tasks;
using CompanyName.ProjectName.DataDictionaryManagement.DataDictionaries.Dtos;
using Shouldly;
using Xunit;
namespace CompanyName.ProjectName.DataDictionaryManagement.DataDictionaries
{
public class DataDictionaryAppService_Tests : DataDictionaryManagementApplicationTestBase
{
private readonly IDataDictionaryAppService _dataDictionaryAppService;
public DataDictionaryAppService_Tests()
{
_dataDictionaryAppService = GetRequiredService<IDataDictionaryAppService>();
}
[Fact]
public async Task Test_GetPagingListAsync_Ok()
{
var result = await _dataDictionaryAppService.GetPagingListAsync(new PagingDataDictionaryInput()
{
Filter = "Gender"
});
result.TotalCount.ShouldBe(1);
result.Items.FirstOrDefault().DisplayText.ShouldBe("性别");
var result1 = await _dataDictionaryAppService.GetPagingListAsync(new PagingDataDictionaryInput()
{
Filter = "性别"
});
result1.TotalCount.ShouldBe(1);
result1.Items.FirstOrDefault().Code.ShouldBe("Gender");
}
[Fact]
public async Task Test_CreateAsync_Ok()
{
var input = new CreateDataDictinaryInput()
{
Code = "Xunit",
DisplayText = "单元测试"
};
await _dataDictionaryAppService.CreateAsync(input);
var result = await _dataDictionaryAppService.GetPagingListAsync(new PagingDataDictionaryInput());
result.TotalCount.ShouldBe(2);
}
[Fact]
public async Task Test_CreateDetailAsync_Ok()
{
var input = new CreateDataDictinaryDetailInput()
{
Id = DataDictionaryManagementConsts.SeedDataDictionaryId,
Code = "Detail",
DisplayText = "明细",
Description = "单元测试",
};
await _dataDictionaryAppService.CreateDetailAsync(input);
var result = await _dataDictionaryAppService.GetPagingDetailListAsync(
new PagingDataDictionaryDetailInput()
{
DataDictionaryId = DataDictionaryManagementConsts.SeedDataDictionaryId,
Filter = "Detail"
}
);
result.Items.Any(e => e.Code == "Detail" && e.IsEnabled == true).ShouldBeTrue();
}
}
}
Loading…
Cancel
Save