コード例 #1
0
ファイル: FiltersTests.cs プロジェクト: MaQuanXin/Moonglade
    public void ClearPagingCountCache_OnActionExecuted()
    {
        var ctx = MakeActionExecutedContext();

        var mockedCache = Create.MockedMemoryCache();
        var blogCache   = new BlogMemoryCache(mockedCache);

        blogCache.GetOrCreate(CacheDivision.General, "postcount", _ => FakeData.Int2);
        blogCache.GetOrCreate(CacheDivision.General, "ali", _ => FakeData.ShortString1);
        blogCache.GetOrCreate(CacheDivision.PostCountCategory, "pdd", _ => 007);
        blogCache.GetOrCreate(CacheDivision.PostCountTag, "hw", _ => FakeData.Int1);

        var att = new ClearBlogCache(BlogCacheType.PagingCount, 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(FakeData.ShortString1, ali);
        Assert.AreEqual(0, pdd);
        Assert.AreEqual(0, hw);
    }
コード例 #2
0
ファイル: FiltersTests.cs プロジェクト: MaQuanXin/Moonglade
    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 ClearBlogCache(BlogCacheType.SiteMap, blogCache);

        att.OnActionExecuted(ctx);

        var work996 = mockedCache.Get <string>("General-sitemap");

        Assert.AreEqual(null, work996);
    }
コード例 #3
0
ファイル: FiltersTests.cs プロジェクト: MaQuanXin/Moonglade
    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 ClearBlogCache(BlogCacheType.Subscription, 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);
    }
コード例 #4
0
ファイル: FiltersTests.cs プロジェクト: xrcdev/Moonglade
        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);
        }