|
@@ -46,7 +46,7 @@ public class SnapshotUserApplicationTest : TestBase
|
|
|
|
|
|
var citizen = await _citizenRepository.Queryable()
|
|
|
.LeftJoin<CitizenRelationSafetyType>((citizen, relation) => relation.CitizenId == citizen.Id)
|
|
|
- .Where((citizen, relation) => relation.Id == null)
|
|
|
+ .Where((citizen, relation) => relation.CitizenId == null)
|
|
|
.FirstAsync();
|
|
|
var addDto = new AddCitizenRelationSafetyTypeInDto
|
|
|
{
|
|
@@ -67,5 +67,44 @@ public class SnapshotUserApplicationTest : TestBase
|
|
|
item.SafetyTypeId.ShouldBe(safetyType.Id);
|
|
|
item.CitizenId.ShouldBe(citizen.Id);
|
|
|
item.CitizenName.ShouldBe(citizen.Name);
|
|
|
+
|
|
|
+ var newSafetyTypeXuanChuan = new SafetyType { Name = "宣传员" };
|
|
|
+ var safetyTypeXuanChuan = await _safetyTypeRepository.Queryable()
|
|
|
+ .Where(m => m.Name == newSafetyTypeXuanChuan.Name).FirstAsync();
|
|
|
+ safetyTypeXuanChuan ??= new SafetyType
|
|
|
+ {
|
|
|
+ Id = await _safetyTypeRepository.AddAsync(newSafetyTypeXuanChuan)
|
|
|
+ };
|
|
|
+ addDto = new AddCitizenRelationSafetyTypeInDto
|
|
|
+ {
|
|
|
+ CitizenIds = [citizen.Id],
|
|
|
+ SafetyTypeId = safetyTypeXuanChuan.Id,
|
|
|
+ };
|
|
|
+ await _snapshotUserApplication.AddCitizenRelationSafetyType(addDto, CancellationToken.None);
|
|
|
+ var deleteInDto = new DeleteCitizenRelationSafetyTypeInDto
|
|
|
+ {
|
|
|
+ Items =
|
|
|
+ [
|
|
|
+ new() {
|
|
|
+ CitizenId = citizen.Id,
|
|
|
+ SafetyTypeId = safetyTypeXuanChuan.Id
|
|
|
+ }
|
|
|
+ ]
|
|
|
+ };
|
|
|
+ await _snapshotUserApplication.DeleteCitizenRelationSafetyAsync(deleteInDto);
|
|
|
+
|
|
|
+ items = await _snapshotUserApplication.GetCitizenRelationSafetyType(inDto).ToListAsync();
|
|
|
+ item = items.FirstOrDefault(m => m.CitizenId == citizen.Id && m.SafetyTypeId == safetyType.Id);
|
|
|
+ item.ShouldBeNull();
|
|
|
+ inDto = new CitizenRelationSafetyTypeInDto
|
|
|
+ {
|
|
|
+ SafetyTypeId = safetyTypeXuanChuan.Id
|
|
|
+ };
|
|
|
+ items = await _snapshotUserApplication.GetCitizenRelationSafetyType(inDto).ToListAsync();
|
|
|
+ item = items.FirstOrDefault(m => m.CitizenId == citizen.Id && m.SafetyTypeId == safetyTypeXuanChuan.Id);
|
|
|
+ item.SafetyTypeName.ShouldBe(safetyTypeXuanChuan.Name);
|
|
|
+ item.SafetyTypeId.ShouldBe(safetyTypeXuanChuan.Id);
|
|
|
+ item.CitizenId.ShouldBe(citizen.Id);
|
|
|
+ item.CitizenName.ShouldBe(citizen.Name);
|
|
|
}
|
|
|
}
|