コード例 #1
0
        private static List <CacheKey> FillCacheSet(int setIndex, SetAssociativeCache <CacheKey, CacheValue> cache)
        {
            List <CacheKey> keyList = new List <CacheKey>();

            cache.Clear();

            for (int i = 0; i < cache.NumberOfWays; i++)
            {
                var empNumber = new CacheKey($"{i}", setIndex);
                var empName   = new CacheValue($"Employee {i}");

                cache.Add(empNumber, empName);
                keyList.Add(empNumber);
                ;
            }

            return(keyList);
        }
コード例 #2
0
        public void Clear_Should_Remove_All_Cache_Items()
        {
            // Arrange
            var empNumber1 = new CacheKey("001");
            var empName1   = new CacheValue("Steve Jobs");

            cache.Add(empNumber1, empName1);

            var empNumber2 = new CacheKey("002");
            var empName2   = new CacheValue("Bill Gates");

            cache.Add(empNumber2, empName2);
            cache.Count.Should().Be(2);

            // Act
            cache.Clear();

            // Assert
            cache.Count.Should().Be(0);
        }