OrderSnapshotApplicationTest.cs 3.7 KB

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