public async Task TimeLimitedLookupsArePresentAndMatchExpectedCount(TypeOfLimitedLifeLookup thisKey, int expectedCount) { // arrange var internalDataCache = new InternalDataCache(); // act await NewService(internalDataCache).PopulateAsync(CancellationToken.None); // assert Assert.True(internalDataCache.LimitedLifeLookups.ContainsKey(thisKey)); Assert.Equal(expectedCount, internalDataCache.LimitedLifeLookups[thisKey].Count); }
/// <summary> /// Adds lookups. /// </summary> /// <param name="forThisKey">For this key.</param> /// <param name="usingSource">using source.</param> /// <param name="addToCache">add to cache.</param> public void AddLookups(TypeOfLimitedLifeLookup forThisKey, XElement usingSource, InternalDataCache addToCache) { var lookups = BuildDictionaryLookupsWithValidityPeriods(usingSource, $"{forThisKey}"); addToCache.LimitedLifeLookups.Add(forThisKey, lookups); }
public bool IsVaguelyCurrent(TypeOfLimitedLifeLookup lookupKey, string candidate, DateTime referenceDate) { return(Contains(lookupKey, candidate) && _internalCache.LimitedLifeLookups[lookupKey].TryGetValue(candidate, out var value) && IsBetween(DateTime.MinValue, value.ValidTo, referenceDate)); }
public bool IsExpired(TypeOfLimitedLifeLookup lookupKey, string candidate, DateTime referenceDate) { return(Contains(lookupKey, candidate) && _internalCache.LimitedLifeLookups[lookupKey].TryGetValue(candidate, out var value) && referenceDate > value.ValidTo); }
public bool IsCurrent(TypeOfLimitedLifeLookup lookupKey, int candidate, DateTime referenceDate) { return(IsCurrent(lookupKey, $"{candidate}", referenceDate)); }
public bool Contains(TypeOfLimitedLifeLookup lookupKey, string keyCandidate) { return(!string.IsNullOrWhiteSpace(keyCandidate) && _internalCache.LimitedLifeLookups[lookupKey].ContainsKey(keyCandidate)); }
public bool Contains(TypeOfLimitedLifeLookup lookupKey, int candidate) { return(Contains(lookupKey, $"{candidate}")); }
/// <summary> /// Determines whether [contains] [the specified lookup key]. /// </summary> /// <param name="lookupKey">The lookup key.</param> /// <param name="keyCandidate">The candidate.</param> /// <returns> /// <c>true</c> if [contains] [the specified lookup key]; otherwise, <c>false</c>. /// </returns> public bool Contains(TypeOfLimitedLifeLookup lookupKey, string keyCandidate) { return(It.Has(keyCandidate) && InternalCache.LimitedLifeLookups[lookupKey].ContainsKey(keyCandidate)); }