public async Task Should_Create_Dic() { var dic = new CreateDataDictionaryDto() { Name = "Group01", Description = "单元测试01" }; var result = await _dicAppService.CreateAsync(dic); result.Code.ShouldBe(200); }
public async Task Create_DataDictionary_Test() { var input = new CreateDataDictionaryDto { Name = "外贸", Description = "I-进口,E-出口,C-国产" }; var create = await _dictionaryAppService.CreateAsync(input); create.ShouldNotBeNull(); create.Name.ShouldBe("外贸"); }
public async Task Create_DataDictionaryDetail_Test() { var input = new CreateDataDictionaryDto { Name = "外贸", Description = "I-进口,E-出口,C-国产" }; var master = await _dictionaryAppService.CreateAsync(input); master.ShouldNotBeNull(); var inputC = new CreateDataDictionaryDetailDto { Pid = master.Id, Label = "国产", Value = "G", Sort = 1 }; (await _dictionaryDetailAppService.CreateAsync(inputC)).ShouldNotBeNull(); var inputI = new CreateDataDictionaryDetailDto { Pid = master.Id, Label = "进口", Value = "I", Sort = 2 }; (await _dictionaryDetailAppService.CreateAsync(inputI)).ShouldNotBeNull(); var inputE = new CreateDataDictionaryDetailDto { Pid = master.Id, Label = "出口", Value = "E", Sort = 3 }; (await _dictionaryDetailAppService.CreateAsync(inputE)).ShouldNotBeNull(); var items = (await _dictionaryDetailAppService.GetListAsync(new GetDictionaryDetailInputDto { SkipCount = 0, Sorting = "sort desc", MaxResultCount = 20, Pid = master.Id })).Items; items.FirstOrDefault().ShouldNotBeNull(); items.Count.ShouldBeGreaterThan(0); items.FirstOrDefault().Label.ShouldBe("出口"); }
public async Task <ApiResult> CreateAsync(CreateDataDictionaryDto input) { var count = await _dataDictionaryRepository.Where(e => e.Name == input.Name.Trim()).CountAsync(); if (count > 0) { return(ApiResult.Error($"{input.Name} {_localizer["DataExistence"]}")); } var entity = new DataDictionary(_guidGenerator.Create(), input.Name, _currentUser.TenantId, input.Description); await _dataDictionaryRepository.InsertAsync(entity); return(ApiResult.Ok()); }
public async Task Create_DataDictionary_SetTenantId_Test() { //TODO:Set tenant _fakeCurrentTenant.Id.Returns(DataDictionaryBuilder.TenantId1); var input = new CreateDataDictionaryDto { Name = DataDictionaryBuilder.TenantId1 + "-外贸", Description = "I-进口,E-出口,C-国产", Sort = 100 }; var create = await _dictionaryAppService.CreateAsync(input); create.ShouldNotBeNull(); var repository = GetService <IRepository <DataDictionary, Guid> >(); var result = await repository.GetAsync(create.Id); result.ShouldNotBeNull(); result.TenantId.ShouldNotBeNull(); result.TenantId.ShouldNotBe(Guid.Empty); result.TenantId.ShouldBe(DataDictionaryBuilder.TenantId1); }