OrderSnapshotApplicationTest.cs 3.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. using Hotline.Api.Controllers;
  2. using Hotline.Application.Snapshot;
  3. using Hotline.Caching.Interfaces;
  4. using Hotline.Identity.Accounts;
  5. using Hotline.Identity.Roles;
  6. using Hotline.Repository.SqlSugar.Extensions;
  7. using Hotline.Share.Dtos;
  8. using Hotline.Share.Dtos.Snapshot;
  9. using Hotline.Share.Requests;
  10. using Hotline.Share.Tools;
  11. using Hotline.Snapshot.Interfaces;
  12. using Hotline.Tests.Mock;
  13. using Hotline.Users;
  14. using Microsoft.AspNetCore.Http;
  15. using Microsoft.Extensions.DependencyInjection;
  16. using Shouldly;
  17. using XF.Domain.Repository;
  18. namespace Hotline.Tests.Application;
  19. public class OrderSnapshotApplicationTest : TestBase
  20. {
  21. private readonly OrderServiceMock _orderServiceMock;
  22. private readonly ISystemDicDataCacheManager _systemDicDataCacheManager;
  23. private readonly IOrderSnapshotRepository _orderSnapshotRepository;
  24. private readonly IOrderSnapshotApplication _orderSnapshotApplication;
  25. 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)
  26. {
  27. _orderServiceMock = orderServiceMock;
  28. _systemDicDataCacheManager = systemDicDataCacheManager;
  29. _orderSnapshotRepository = orderSnapshotRepository;
  30. _orderSnapshotApplication = orderSnapshotApplication;
  31. }
  32. /// <summary>
  33. /// 随手拍办理流程
  34. /// 工单标注 : 验证数据是否保存正确
  35. /// 获取已标注集合: 验证是否有已标注的数据
  36. /// </summary>
  37. /// <returns></returns>
  38. [Fact]
  39. public async Task SnapshotWrokflow_Test()
  40. {
  41. var snapshotLabels = _systemDicDataCacheManager.SnapshotOrderLabel;
  42. var inputLable = snapshotLabels.Where(m => m.DicDataValue == "bss").ToList();
  43. var order = _orderServiceMock.CreateSnapshotOrder(SetWeiXin)
  44. .办理到工单标注(SetZuoXi)
  45. .办理到派单员(SetZuoXi, false)
  46. .办理到归档(SetZuoXi)
  47. .发布工单(SetZuoXi, inputLable.Select(m => new Kv { Key = m.DicDataValue, Value = m.DicDataName}).ToList())
  48. .GetCreateResult();
  49. order.Id.ShouldNotBeNull();
  50. var snapshot = await _orderSnapshotRepository.GetAsync(order.Id);
  51. // 验证工单标注是否生效
  52. snapshot.ShouldNotBeNull();
  53. snapshot.IsTruthDepartment.ShouldBe(false);
  54. snapshot.LabelName.ShouldBe(string.Join('|', inputLable.Select(m => m.DicDataName)));
  55. snapshot.Labels.ShouldNotBeNull();
  56. snapshot.Labels.Count.ShouldBe(inputLable.Count);
  57. snapshot.IsSafetyDepartment.ShouldBe(false);
  58. var labelLog = await _orderSnapshotApplication.GetLabelOrderSnapshotLogItems(new LabelOrderSnapshotLogItemsInDto()).ToPagedListAsync(new PagedRequest());
  59. labelLog.Items.Any(m => m.Title.IsNullOrEmpty()).ShouldBe(false);
  60. labelLog.Items.Any(m => m.SourceChannel.IsNullOrEmpty()).ShouldBe(false);
  61. var sigedItems = await _orderSnapshotApplication.GetLabeledOrderSnapshotItems(new LabeledOrderSnapshotItemsInDto()).ToListAsync();
  62. sigedItems.Any(m => m.OrderId == order.Id).ShouldBe(true);
  63. }
  64. }