Replies: 1 comment 1 reply
-
I faced the same issue in on of my projects and the easiest and least brittle solution is to introduce a humble object as a facade: public sealed class LocalStorageService : ILocalStorageService
{
private readonly ProtectedLocalStorage localStorage;
public LocalStorageService(ProtectedLocalStorage localStorage)
{
this.localStorage = localStorage;
}
public async ValueTask<bool> ContainKeyAsync(string key) => (await localStorage.GetAsync<object>(key)).Success;
public async ValueTask<T> GetItemAsync<T>(string key) => (await localStorage.GetAsync<T>(key)).Value;
public async ValueTask SetItemAsync<T>(string key, T value) => await localStorage.SetAsync(key, value);
} Now you can use |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi,
I'd like to test Blazor state management which persists data in ProtectedSessionStorage.
I followed this and bUnit documentation but no success, yet.
These my source:
The test:
And this is the error message which I tried but no success:
The setup methods are available on an instance of the BunitJSInterop or
BunitJSModuleInterop type. The standard BunitJSInterop is available
through the TestContext.JSInterop property, and a BunitJSModuleInterop
instance is returned from calling SetupModule on a BunitJSInterop instance.
Beta Was this translation helpful? Give feedback.
All reactions