SystemSettingCacheManagerTest.cs 3.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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.Snapshot.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.Repository;
  18. namespace Hotline.Application.Tests.Application;
  19. public class SystemSettingCacheManagerTest : TestBase
  20. {
  21. private readonly ISystemSettingCacheManager _systemSettingCacheManager;
  22. private readonly ISystemDicDataCacheManager _systemDicDataCacheManager;
  23. private readonly IRepository<SystemSetting> _systemSettingRepository;
  24. 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)
  25. {
  26. _systemSettingCacheManager = systemSettingCacheManager;
  27. _systemDicDataCacheManager = systemDicDataCacheManager;
  28. _systemSettingRepository = systemSettingRepository;
  29. }
  30. [Fact]
  31. public void CancelPublishOrderEnabled_Test()
  32. {
  33. var dd = DateTime.Parse("11/19/2024 18:08:00");
  34. _systemSettingCacheManager.CallSyncUnPushDateTime.ShouldBe(DateTime.Parse("2024/11/19 18:08:00"));
  35. //var result = _systemSettingCacheManager.CancelPublishOrderEnabled;
  36. //result.ShouldBeTrue();
  37. var seconds = _systemSettingCacheManager.VisitCallDelaySecond;
  38. seconds.ShouldBe(60);
  39. var delaySecond = _systemSettingCacheManager.DefaultVisitSmsDelaySecond;
  40. delaySecond.ShouldBe(172800);
  41. var delaySecondEntity = _systemSettingRepository.GetAsync("08dc0681-a6d2-4ce7-877d-db65f846d523");
  42. delaySecondEntity.ShouldNotBeNull("DefaultVisitSmsDelaySecond 系统设置为NULL");
  43. _systemSettingCacheManager.GetAboutToExpireVersion.ShouldBe(0);
  44. _systemSettingCacheManager.WxOpenAppId.ShouldNotBeNull();
  45. _systemSettingCacheManager.WxOpenAppSecret.ShouldNotBeNull();
  46. _systemSettingCacheManager.VisitCallDelaySecond.ShouldNotBe(0);
  47. _systemSettingCacheManager.AutomaticPublishOrder.ShouldBe(true);
  48. //_systemSettingCacheManager.CancelPublishOrderEnabled.ShouldBe(true);
  49. _systemDicDataCacheManager.RemoveSysDicDataCache(SysDicTypeConsts.Workplace);
  50. var workplace = _systemDicDataCacheManager.Workplace;
  51. workplace.ShouldNotBeNull();
  52. workplace.Count.ShouldNotBe(0);
  53. _systemDicDataCacheManager.RemoveSysDicDataCache(SysDicTypeConsts.WorkplaceName);
  54. var workArea = _systemDicDataCacheManager.WorkplaceName;
  55. workArea.ShouldNotBeNull();
  56. workArea.Count.ShouldNotBe(0);
  57. _systemDicDataCacheManager.RemoveSysDicDataCache(SysDicTypeConsts.SnapshotBulletinType);
  58. var snapshotBulletinType = _systemDicDataCacheManager.SnapshotBulletinType;
  59. snapshotBulletinType.ShouldNotBeNull();
  60. snapshotBulletinType.Count.ShouldNotBe(0);
  61. }
  62. }