Example #1
0
        public void EmptyAllTest()
        {
            //Saves the cache and pass it a timespan for expiration
            barrel.Add(key: url, data: monkeys, expireIn: TimeSpan.FromDays(1));


            var cached = barrel.Get <IEnumerable <Monkey> >(url);

            Assert.IsNotNull(cached);

            barrel.EmptyAll();

            cached = barrel.Get <IEnumerable <Monkey> >(url);

            Assert.IsNull(cached);
        }
Example #2
0
        public void SetCacheDirectoryAfterInitialize()
        {
            IBarrel barrel = null;
            var     folder = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);

            SetupBarrel(ref barrel);
            barrel.EmptyAll();

            BarrelUtils.SetBaseCachePath(folder);
        }
Example #3
0
        public MonkeyCacheActiveDirectoryProvider(IActiveDirectoryProvider activeDirectoryProvider, string applicationId, double expiryLengthDays = 1.0, bool refresh = false) : base(activeDirectoryProvider)
        {
            Barrel.ApplicationId = applicationId;
            _barrel           = Barrel.Current;
            _expiryLengthDays = expiryLengthDays;

            if (refresh)
            {
                _barrel.EmptyAll();
            }
            else
            {
                _barrel.EmptyExpired();
            }
        }
Example #4
0
        public void GetKeysTest()
        {
            barrel.EmptyAll();

            var keysToStore = new[] { "One", "Two", "Three" }.OrderBy(x => x).ToArray();

            foreach (var item in keysToStore)
            {
                barrel.Add(key: item, data: item, expireIn: TimeSpan.FromDays(1));
            }

            var test1 = barrel.GetKeys(CacheState.Active | CacheState.Expired);

            var cachedKeys = barrel.GetKeys().OrderBy(x => x).ToArray();

            Assert.IsNotNull(cachedKeys);
            Assert.IsTrue(cachedKeys.Any());
            for (var i = 0; i < cachedKeys.Length; i++)
            {
                Assert.AreEqual(keysToStore[i], cachedKeys[i]);
            }
        }
        public MainViewModel(INavigationService navigationService, IPageDialogService dialogService, IEventAggregator eventAggregator, IBarrel barrel, ITeamsService teamService) : base(navigationService, dialogService)
        {
            Title = "Main view";

            _barrel          = barrel;
            _teamService     = teamService;
            _eventAggregator = eventAggregator;

            PanelCommand            = new DelegateCommand(() => IsPanelVisible = !IsPanelVisible);
            ShowLoadingCommand      = new DelegateCommand(async() => await ShowLoading());
            GoToPlayersViewCommand  = new DelegateCommand(async() => await GoToPlayersView());
            ClearCacheCommand       = new DelegateCommand(() => _barrel.EmptyAll());
            CrashCommand            = new DelegateCommand(async() => await Crash());
            NavigateToDetailCommand = new DelegateCommand(async() => await NavigateToDetail());
            SignInCommand           = new DelegateCommand(async() => await SignIn());
            SignOutCommand          = new DelegateCommand(async() => await SignOut());

            _eventAggregator.GetEvent <MyEvent>()?.Subscribe(async() =>
            {
                await DialogService.DisplayAlertAsync("Notification", "Show notification", "Ok");
            });
        }
Example #6
0
 public void Teardown()
 {
     barrel?.EmptyAll();
 }
Example #7
0
 public void EmptyAllMonkeys()
 {
     file.EmptyAll();
 }
Example #8
0
        public Task Clear(CancellationToken cancellationToken = default)
        {
            _barrel.EmptyAll();

            return(Task.CompletedTask);
        }
Example #9
0
 public Task <bool> RemoveAll()
 {
     _barrel.EmptyAll();
     return(Task.FromResult(true));
 }