Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 3
0
 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));
 }
Ejemplo n.º 4
0
 public bool IsExpired(TypeOfLimitedLifeLookup lookupKey, string candidate, DateTime referenceDate)
 {
     return(Contains(lookupKey, candidate) &&
            _internalCache.LimitedLifeLookups[lookupKey].TryGetValue(candidate, out var value) &&
            referenceDate > value.ValidTo);
 }
Ejemplo n.º 5
0
 public bool IsCurrent(TypeOfLimitedLifeLookup lookupKey, int candidate, DateTime referenceDate)
 {
     return(IsCurrent(lookupKey, $"{candidate}", referenceDate));
 }
Ejemplo n.º 6
0
 public bool Contains(TypeOfLimitedLifeLookup lookupKey, string keyCandidate)
 {
     return(!string.IsNullOrWhiteSpace(keyCandidate) &&
            _internalCache.LimitedLifeLookups[lookupKey].ContainsKey(keyCandidate));
 }
Ejemplo n.º 7
0
 public bool Contains(TypeOfLimitedLifeLookup lookupKey, int candidate)
 {
     return(Contains(lookupKey, $"{candidate}"));
 }
Ejemplo n.º 8
0
 /// <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));
 }