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
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
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();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user