using VendingMachine.Application.Services;
namespace VendingMachine.Tests;
///
/// 内存版验证码存储,用于单元测试
///
public class InMemoryVerificationCodeStore : IVerificationCodeStore
{
private readonly Dictionary _store = new();
public IReadOnlyDictionary Store => _store;
public Task StoreCodeAsync(string key, string code, TimeSpan expiry)
{
_store[key] = code;
return Task.CompletedTask;
}
public Task GetCodeAsync(string key)
{
return Task.FromResult(_store.TryGetValue(key, out var val) ? val : null);
}
public Task DeleteCodeAsync(string key)
{
_store.Remove(key);
return Task.CompletedTask;
}
}