Merge pull request #914 from 13xforever/vnext

Honker plz
This commit is contained in:
clienthax 2022-11-10 16:19:28 +00:00 committed by GitHub
commit 8b8f0fd149
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 32 additions and 0 deletions

View File

@ -0,0 +1,31 @@
using System;
using System.Collections.Generic;
using CompatBot.Utils;
using Microsoft.Extensions.Caching.Memory;
using NUnit.Framework;
namespace Tests;
[TestFixture]
public class MemoryCacheExtensionTests
{
[Test]
public void GetCacheKeysTest()
{
var cache = new MemoryCache(new MemoryCacheOptions { ExpirationScanFrequency = TimeSpan.FromHours(1) });
Assert.That(cache.GetCacheKeys<int>().Count, Is.EqualTo(0));
cache.Set(13, "val13");
Assert.That(cache.GetCacheKeys<int>().Count, Is.EqualTo(1));
}
[Test]
public void GetCacheEntriesTest()
{
var cache = new MemoryCache(new MemoryCacheOptions { ExpirationScanFrequency = TimeSpan.FromHours(1) });
Assert.That(cache.GetCacheKeys<int>().Count, Is.EqualTo(0));
cache.Set(13, "val13");
Assert.That(cache.GetCacheKeys<int>().Count, Is.EqualTo(1));
}
}

View File

@ -5,6 +5,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="DuoVia.FuzzyStrings" Version="2.1.0" />
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="7.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.4.0" />
<PackageReference Include="NUnit" Version="3.13.3" />
<PackageReference Include="NUnit3TestAdapter" Version="4.3.0">