public void ClearPagingCountCache_OnActionExecuted() { var ctx = MakeActionExecutedContext(); var mockedCache = Create.MockedMemoryCache(); var blogCache = new BlogMemoryCache(mockedCache); blogCache.GetOrCreate(CacheDivision.General, "postcount", _ => 996); blogCache.GetOrCreate(CacheDivision.General, "ali", _ => "fubao"); blogCache.GetOrCreate(CacheDivision.PostCountCategory, "pdd", _ => 007); blogCache.GetOrCreate(CacheDivision.PostCountTag, "hw", _ => 251); var att = new ClearPagingCountCache(blogCache); att.OnActionExecuted(ctx); var postcount = mockedCache.Get <int>("General-postcount"); var ali = mockedCache.Get <string>("General-ali"); var pdd = mockedCache.Get <int>("PostCountCategory-pdd"); var hw = mockedCache.Get <int>("PostCountTag-hw"); Assert.AreEqual(0, postcount); Assert.AreEqual("fubao", ali); Assert.AreEqual(0, pdd); Assert.AreEqual(0, hw); }
public async Task GetAll_OK() { var mockedCache = Create.MockedMemoryCache(); var memBc = new BlogMemoryCache(mockedCache); var handler = new GetCategoriesQueryHandler(_mockCatRepo.Object, memBc); var result = await handler.Handle(new(), default);
public async Task GetAll_OK() { var mockedCache = Create.MockedMemoryCache(); var memBc = new BlogMemoryCache(mockedCache); var svc = CreateService(memBc); var result = await svc.GetAllAsync(); _mockCatRepo.Verify(p => p.SelectAsync(It.IsAny <Expression <Func <CategoryEntity, Category> > >())); }
public void ClearSiteMapCache_OnActionExecuted() { var ctx = MakeActionExecutedContext(); var mockedCache = Create.MockedMemoryCache(); var blogCache = new BlogMemoryCache(mockedCache); blogCache.GetOrCreate(CacheDivision.General, "sitemap", _ => "The 996 working hour system (Chinese: 996工作制) is a work schedule commonly practiced by some companies in the People's Republic of China. It derives its name from its requirement that employees work from 9:00 am to 9:00 pm, 6 days per week; i.e. 72 hours per week. A number of Chinese internet companies have adopted this system as their official work schedule. Critics argue that the 996 working hour system is a flagrant violation of Chinese law."); var att = new ClearSiteMapCache(blogCache); att.OnActionExecuted(ctx); var work996 = mockedCache.Get <string>("General-sitemap"); Assert.AreEqual(null, work996); }
public void ClearSubscriptionCache_OnActionExecuted() { var ctx = MakeActionExecutedContext(); var mockedCache = Create.MockedMemoryCache(); var blogCache = new BlogMemoryCache(mockedCache); blogCache.GetOrCreate(CacheDivision.General, "rss", _ => "The culture of overtime work has a long history in Chinese IT companies, where the focus is typically on speed and cost reduction. Companies employ a range of measures, such as reimbursing taxi fares for employees who remain working at the office late into the night, to encourage overtime work."); blogCache.GetOrCreate(CacheDivision.General, "atom", _ => "On 26 March 2019, the 996.ICU repository and website were created. The repository states that the name \"996.icu\" refers to how developers who work under the 996 system (9AM–9PM, 6 days per week) would risk poor health and a possible stay in an intensive care unit. The movement's slogan is \"developers' lives matter\"."); var att = new ClearSubscriptionCache(blogCache); att.OnActionExecuted(ctx); var work996 = mockedCache.Get <string>("General-rss"); var sickICU = mockedCache.Get <string>("General-atom"); Assert.AreEqual(null, work996); Assert.AreEqual(null, sickICU); }
public void ClearBlogCache_OnActionExecuted() { var ctx = MakeActionExecutedContext(); var mockedCache = Create.MockedMemoryCache(); var blogCache = new BlogMemoryCache(mockedCache); blogCache.GetOrCreate(CacheDivision.General, "pdd-overwork-death", _ => "你们看看底层的人民,哪一个不是用命换钱," + "我一直不以为是资本的问题,而是这个社会的问题," + "这是一个用命拼的时代,你可以选择安逸的日子," + "但你就要选择安逸带来的后果," + "人是可以控制自己的努力的,我们都可以"); var att = new ClearBlogCache(CacheDivision.General, "pdd-overwork-death", blogCache); att.OnActionExecuted(ctx); var pddReply = mockedCache.Get <string>("General-pdd-overwork-death"); Assert.AreEqual(null, pddReply); }
public void Setup() { _memoryCache = Create.MockedMemoryCache(); _blogCache = new(_memoryCache); }