Пример #1
0
        public async Task ClearsAnyItemsInTheStore()
        {
            // Arrange
            var item1 = new TestObject(1, "Jane Smith");
            var item2 = new TestObject(2, "John Smith");

            await _sut.SetItemAsync("Item1", item1);

            await _sut.SetItemAsync("Item2", item2);

            // Act
            await _sut.ClearAsync();

            // Assert
            Assert.Equal(0, await _storageProvider.LengthAsync());
        }
Пример #2
0
        public async Task InitializeAsync()
        {
            try
            {
                var token = await _localStorage.GetAsync <string>(LOCAL_USER_LOCAL_STORAGE_KEY);

                if (!string.IsNullOrWhiteSpace(token))
                {
                    await LoginAsync(token);
                }
            }
            catch (Exception ex)
            {
                _logger.Error($"Deserialize local user failed or login failed, require to re-login ex: {ex.Message}.");
                await _localStorage.ClearAsync();
            }
        }
Пример #3
0
        async Task HandleLogout()
        {
            await LocalStorageService.ClearAsync();

            NavigationManager.NavigateTo("/");
        }