/
githubmirror
/
aspnetcore
Обзор
Документация
Войти
/
githubmirror
/
aspnetcore
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
src/Components/Endpoints/test/HybridCacheViewStoreTest.cs
42 строки
2 KB
Daria Tiurina
Fix API for CacheView (#67776)
14 июл 2026, 18:37
Не верифицирован
14 июл 2026, 18:37
564927c
Код
Авторство
О чём код?
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. #nullable enable using Microsoft.Extensions.Caching.Hybrid; namespace Microsoft.AspNetCore.Components.Endpoints; public class HybridCacheViewStoreTest { [Fact] public void GetOrCreateAsync_WithExpiresSliding_ThrowsNotSupported() { var store = new HybridCacheViewStore(new StubHybridCache()); var options = new CacheStoreOptions { ExpiresSliding = TimeSpan.FromMinutes(1) }; var ex = Assert.Throws<NotSupportedException>(() => { store.GetOrCreateAsync("key", Factory, options, default); }); Assert.Contains(nameof(CacheView.ExpiresSliding), ex.Message); } private static ValueTask<SerializedRenderFragment> Factory(CancellationToken cancellationToken) => ValueTask.FromResult(new SerializedRenderFragment()); private sealed class StubHybridCache : HybridCache { public override ValueTask<T> GetOrCreateAsync<TState, T>(string key, TState state, Func<TState, CancellationToken, ValueTask<T>> factory, HybridCacheEntryOptions? options = null, IEnumerable<string>? tags = null, CancellationToken cancellationToken = default) => throw new NotImplementedException(); public override ValueTask SetAsync<T>(string key, T value, HybridCacheEntryOptions? options = null, IEnumerable<string>? tags = null, CancellationToken cancellationToken = default) => throw new NotImplementedException(); public override ValueTask RemoveAsync(string key, CancellationToken cancellationToken = default) => throw new NotImplementedException(); public override ValueTask RemoveByTagAsync(string tag, CancellationToken cancellationToken = default) => throw new NotImplementedException(); } }