SystemSettingCacheManagerTest.cs 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. using Hotline.Api.Controllers;
  2. using Hotline.Caching.Interfaces;
  3. using Hotline.Identity.Accounts;
  4. using Hotline.Identity.Roles;
  5. using Hotline.Settings;
  6. using Hotline.ThirdAccountDomainServices;
  7. using Hotline.ThirdAccountDomainServices.Interfaces;
  8. using Hotline.Users;
  9. using Microsoft.AspNetCore.Http;
  10. using Microsoft.Extensions.DependencyInjection;
  11. using Shouldly;
  12. using System;
  13. using System.Collections.Generic;
  14. using System.Linq;
  15. using System.Text;
  16. using System.Threading.Tasks;
  17. using XF.Domain.Cache;
  18. using XF.Domain.Repository;
  19. namespace Hotline.Tests.Application;
  20. public class SystemSettingCacheManagerTest : TestBase
  21. {
  22. private readonly ISystemSettingCacheManager _systemSettingCacheManager;
  23. private readonly ISystemDicDataCacheManager _systemDicDataCacheManager;
  24. private readonly IRepository<SystemSetting> _systemSettingRepository;
  25. public SystemSettingCacheManagerTest(IAccountRepository accountRepository, IRepository<Role> roleRepository, UserController userController, IServiceScopeFactory scopeFactory, IRepository<User> userRepository, IHttpContextAccessor httpContextAccessor, ISystemSettingCacheManager systemSettingCacheManager, ISystemDicDataCacheManager systemDicDataCacheManager, IRepository<SystemSetting> systemSettingRepository, IThirdIdentiyService thirdService, IThirdAccountRepository thirdAccount, ITypedCache<SystemSetting> cacheSettingData, ThirdAccounSupplierFactory thirdAccountDomainFactory, IServiceProvider serviceProvider) : base(accountRepository, roleRepository, userController, scopeFactory, userRepository, httpContextAccessor, thirdService, thirdAccount, cacheSettingData, thirdAccountDomainFactory, serviceProvider)
  26. {
  27. _systemSettingCacheManager = systemSettingCacheManager;
  28. _systemDicDataCacheManager = systemDicDataCacheManager;
  29. _systemSettingRepository = systemSettingRepository;
  30. }
  31. [Fact]
  32. public void CancelPublishOrderEnabled_Test()
  33. {
  34. var dd = DateTime.Parse("11/19/2024 18:08:00");
  35. _systemSettingCacheManager.CallSyncUnPushDateTime.ShouldBe(DateTime.Parse("2024/11/19 18:08:00"));
  36. //var result = _systemSettingCacheManager.CancelPublishOrderEnabled;
  37. //result.ShouldBeTrue();
  38. var seconds = _systemSettingCacheManager.VisitCallDelaySecond;
  39. seconds.ShouldBe(60);
  40. var delaySecond = _systemSettingCacheManager.DefaultVisitSmsDelaySecond;
  41. delaySecond.ShouldBe(172800);
  42. var delaySecondEntity = _systemSettingRepository.GetAsync("08dc0681-a6d2-4ce7-877d-db65f846d523");
  43. delaySecondEntity.ShouldNotBeNull("DefaultVisitSmsDelaySecond 系统设置为NULL");
  44. _systemSettingCacheManager.GetAboutToExpireVersion.ShouldBe(0);
  45. _systemSettingCacheManager.WxOpenAppId.ShouldNotBeNull();
  46. _systemSettingCacheManager.WxOpenAppSecret.ShouldNotBeNull();
  47. _systemSettingCacheManager.VisitCallDelaySecond.ShouldNotBe(0);
  48. _systemSettingCacheManager.AutomaticPublishOrder.ShouldBe(true);
  49. //_systemSettingCacheManager.CancelPublishOrderEnabled.ShouldBe(true);
  50. _systemDicDataCacheManager.RemoveSysDicDataCache(SysDicTypeConsts.Workplace);
  51. var workplace = _systemDicDataCacheManager.Workplace;
  52. workplace.ShouldNotBeNull();
  53. workplace.Count.ShouldNotBe(0);
  54. _systemDicDataCacheManager.RemoveSysDicDataCache(SysDicTypeConsts.WorkplaceName);
  55. var workArea = _systemDicDataCacheManager.WorkplaceName;
  56. workArea.ShouldNotBeNull();
  57. workArea.Count.ShouldNotBe(0);
  58. _systemDicDataCacheManager.RemoveSysDicDataCache(SysDicTypeConsts.SnapshotBulletinType);
  59. var snapshotBulletinType = _systemDicDataCacheManager.SnapshotBulletinType;
  60. snapshotBulletinType.ShouldNotBeNull();
  61. snapshotBulletinType.Count.ShouldNotBe(0);
  62. }
  63. }