< Summary

Information
Class: Services.CacheServices.Cache.AppCache
Assembly: Services
File(s): /home/runner/work/Studio2Prod/Studio2Prod/AppRepository/CacheServices/Cache/AppCache.cs
Line coverage
0%
Covered lines: 0
Uncovered lines: 10
Coverable lines: 10
Total lines: 33
Line coverage: 0%
Branch coverage
0%
Covered branches: 0
Total branches: 14
Branch coverage: 0%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor(...)100%210%
GenerateCacheKey(...)0%210140%
GetCache()100%210%

File(s)

/home/runner/work/Studio2Prod/Studio2Prod/AppRepository/CacheServices/Cache/AppCache.cs

#LineLine coverage
 1using Microsoft.Extensions.Caching.Memory;
 2
 3namespace Services.CacheServices.Cache
 4{
 5    public class AppCache
 6    {
 7        protected readonly IMemoryCache _cache;
 8
 09        public AppCache(IMemoryCache memoryCache)
 10        {
 011            _cache = memoryCache;
 012        }
 13
 14        public string GenerateCacheKey(List<Dictionary<string, string>> table)
 15        {
 016            if (table.Count == 0)
 17            {
 018                return "empty_table";
 19            }
 20
 021            var firstValue = table.FirstOrDefault()?.Values.FirstOrDefault() ?? string.Empty;
 022            var middleValue = table.ElementAtOrDefault(table.Count / 2)?.Values.FirstOrDefault() ?? string.Empty;
 023            var lastValue = table.LastOrDefault()?.Values.FirstOrDefault() ?? string.Empty;
 024            return $"{firstValue}_{middleValue}_{lastValue}";
 25        }
 26
 27        public IMemoryCache GetCache()
 28        {
 029            return _cache;
 30        }
 31    }
 32
 33}