SystemSettingCacheManagerTest.cs 3.9 KB

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