Files
Anatolii Grynchuk 85b362e8cd chore: add hrynco common library solution
- add the standalone HrynCo.Common solution and projects
- include the shared common library source and tests
- add package metadata and a repo gitignore
2026-05-01 00:17:34 +03:00

42 lines
1.2 KiB
C#

namespace HrynCo.Common.Tests;
using HrynCo.Common.Caching;
using FluentAssertions;
using Microsoft.Extensions.Caching.Memory;
using Xunit;
public sealed class CachingTests
{
[Fact]
public async Task SessionCredentialStore_ShouldSaveGetAndRemoveValues()
{
using var cache = new MemoryCache(new MemoryCacheOptions());
var store = new InMemorySessionCredentialStore(cache);
Guid userId = Guid.NewGuid();
await store.SaveAsync(userId, "github", "secret", TimeSpan.FromMinutes(5));
(await store.GetAsync(userId, "github")).Should().Be("secret");
await store.RemoveAsync(userId, "github");
(await store.GetAsync(userId, "github")).Should().BeNull();
}
[Fact]
public async Task SessionPromptStore_ShouldSaveGetAndRemoveValues()
{
using var cache = new MemoryCache(new MemoryCacheOptions());
var store = new InMemorySessionPromptStore(cache);
Guid userId = Guid.NewGuid();
await store.SaveAsync(userId, "openai", "prompt", TimeSpan.FromMinutes(5));
(await store.GetAsync(userId, "openai")).Should().Be("prompt");
await store.RemoveAsync(userId, "openai");
(await store.GetAsync(userId, "openai")).Should().BeNull();
}
}