SystemSettingCacheManagerTest.cs 3.4 KB

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