/// <summary> /// Determines whether [the specified lookup key] is current on the given date /// </summary> /// <param name="lookupKey">The lookup key.</param> /// <param name="candidate">The candidate.</param> /// <param name="referenceDate">The reference date.</param> /// <returns> /// <c>true</c> if [the specified lookup] [is current] for the given date; otherwise, <c>false</c>. /// </returns> public bool IsCurrent(LookupTimeRestrictedKey lookupKey, int candidate, DateTime referenceDate) { return(Contains(lookupKey, candidate) && InternalCache.LimitedLifeLookups[lookupKey] .Where(x => x.Key == candidate) .Any(y => IsBetween(y.Value.ValidFrom, y.Value.ValidTo, referenceDate))); }
public async Task TimeLimitedLookupsArePresentAndMatchExpectedCount(LookupTimeRestrictedKey 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(LookupTimeRestrictedKey forThisKey, XElement usingSource, InternalDataCache addToCache) { var lookups = BuildLookupWithValidityPeriods(usingSource, $"{forThisKey}"); addToCache.LimitedLifeLookups.Add(forThisKey, lookups); }
/// <summary> /// As a set. /// </summary> /// <param name="lookupKey">The lookup key.</param> /// <returns>the domain of values pertinent to the coded lookup key</returns> public IDictionary <int, ValidityPeriods> AsASet(LookupTimeRestrictedKey lookupKey) { return(InternalCache.LimitedLifeLookups[lookupKey]); }
/// <summary> /// Determines whether [the specified lookup key] [contains] the value. /// </summary> /// <param name="lookupKey">The lookup key.</param> /// <param name="candidate">The candidate.</param> /// <returns> /// <c>true</c> if [the specified lookup] [contains]; otherwise, <c>false</c>. /// </returns> public bool Contains(LookupTimeRestrictedKey lookupKey, int candidate) { return(InternalCache.LimitedLifeLookups[lookupKey].ContainsKey(candidate)); }