1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 |
- using Hotline.Api.Controllers;
- using Hotline.Application.Snapshot;
- using Hotline.Caching.Interfaces;
- using Hotline.Identity.Accounts;
- using Hotline.Identity.Roles;
- using Hotline.Repository.SqlSugar.Extensions;
- using Hotline.Share.Dtos;
- using Hotline.Share.Dtos.Snapshot;
- using Hotline.Share.Requests;
- using Hotline.Share.Tools;
- using Hotline.Snapshot.Interfaces;
- using Hotline.Tests.Mock;
- using Hotline.Users;
- using Microsoft.AspNetCore.Http;
- using Microsoft.Extensions.DependencyInjection;
- using Shouldly;
- using XF.Domain.Repository;
- namespace Hotline.Tests.Application;
- public class OrderSnapshotApplicationTest : TestBase
- {
- private readonly OrderServiceMock _orderServiceMock;
- private readonly ISystemDicDataCacheManager _systemDicDataCacheManager;
- private readonly IOrderSnapshotRepository _orderSnapshotRepository;
- private readonly IOrderSnapshotApplication _orderSnapshotApplication;
- public OrderSnapshotApplicationTest(IAccountRepository accountRepository, IRepository<Role> roleRepository, UserController userController, IServiceScopeFactory scopeFactory, IRepository<User> userRepository, IHttpContextAccessor httpContextAccessor, IThirdIdentiyService thirdIdentiyService, IThirdAccountRepository thirdAccountRepository, OrderServiceMock orderServiceMock, ISystemDicDataCacheManager systemDicDataCacheManager, IOrderSnapshotRepository orderSnapshotRepository, IOrderSnapshotApplication orderSnapshotApplication) : base(accountRepository, roleRepository, userController, scopeFactory, userRepository, httpContextAccessor, thirdIdentiyService, thirdAccountRepository)
- {
- _orderServiceMock = orderServiceMock;
- _systemDicDataCacheManager = systemDicDataCacheManager;
- _orderSnapshotRepository = orderSnapshotRepository;
- _orderSnapshotApplication = orderSnapshotApplication;
- }
- /// <summary>
- /// 随手拍办理流程
- /// 工单标注 : 验证数据是否保存正确
- /// 获取已标注集合: 验证是否有已标注的数据
- /// </summary>
- /// <returns></returns>
- [Fact]
- public async Task SnapshotWrokflow_Test()
- {
- var snapshotLabels = _systemDicDataCacheManager.SnapshotOrderLabel;
- var inputLable = snapshotLabels.Where(m => m.DicDataValue == "bss").ToList();
- var order = _orderServiceMock.CreateSnapshotOrder(SetWeiXin)
- .办理到工单标注(SetZuoXi)
- .办理到派单员(SetZuoXi, false)
- .办理到归档(SetZuoXi)
- .发布工单(SetZuoXi, inputLable.Select(m => new Kv { Key = m.DicDataValue, Value = m.DicDataName}).ToList())
- .GetCreateResult();
- order.Id.ShouldNotBeNull();
- var snapshot = await _orderSnapshotRepository.GetAsync(order.Id);
- // 验证工单标注是否生效
- snapshot.ShouldNotBeNull();
- snapshot.IsTruthDepartment.ShouldBe(false);
- snapshot.LabelName.ShouldBe(string.Join('|', inputLable.Select(m => m.DicDataName)));
- snapshot.Labels.ShouldNotBeNull();
- snapshot.Labels.Count.ShouldBe(inputLable.Count);
- snapshot.IsSafetyDepartment.ShouldBe(false);
- var labelLog = await _orderSnapshotApplication.GetLabelOrderSnapshotLogItems(new LabelOrderSnapshotLogItemsInDto()).ToPagedListAsync(new PagedRequest());
- labelLog.Items.Any(m => m.Title.IsNullOrEmpty()).ShouldBe(false);
- labelLog.Items.Any(m => m.SourceChannel.IsNullOrEmpty()).ShouldBe(false);
- var sigedItems = await _orderSnapshotApplication.GetLabeledOrderSnapshotItems(new LabeledOrderSnapshotItemsInDto()).ToListAsync();
- sigedItems.Any(m => m.OrderId == order.Id).ShouldBe(true);
- }
- }
|