SystemSettingCacheManagerTest.cs 3.3 KB

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