Beispiel #1
0
        public void MethodExecutedOnlyOnceWhenCached()
        {
            var functionsWithCaching = new FunctionsWithCaching();

            Assert.Equal(3, functionsWithCaching.Add(1, 2));

            Assert.Equal(1, functionsWithCaching.MethodExecutions);


            Assert.Equal(3, functionsWithCaching.Add(1, 2));

            Assert.Equal(1, functionsWithCaching.MethodExecutions);
        }
Beispiel #2
0
        public void CustomMaxSizeWorksSmallerSize()
        {
            LruCacheConfiguration.MaxSize = 2;

            var functionsWithCaching = new FunctionsWithCaching();

            functionsWithCaching.Add(1, 1);
            functionsWithCaching.Add(1, 2);
            functionsWithCaching.Add(1, 3);
            functionsWithCaching.Add(1, 1);


            Assert.Equal(4, functionsWithCaching.MethodExecutions);
        }
Beispiel #3
0
        public void MethodExecutedTwice()
        {
            var functionsWithCaching = new FunctionsWithCaching();

            functionsWithCaching.Add(1, 2);

            Assert.Equal(1, functionsWithCaching.MethodExecutions);



            functionsWithCaching.Add(1, 3);

            Assert.Equal(2, functionsWithCaching.MethodExecutions);
        }
Beispiel #4
0
        public void DefaultMaxSizeIsTenTestEjection()
        {
            var functionsWithCaching = new FunctionsWithCaching();

            functionsWithCaching.Add(1, 1);
            functionsWithCaching.Add(1, 2);
            functionsWithCaching.Add(1, 3);
            functionsWithCaching.Add(1, 4);
            functionsWithCaching.Add(1, 5);
            functionsWithCaching.Add(1, 6);
            functionsWithCaching.Add(1, 7);
            functionsWithCaching.Add(1, 8);
            functionsWithCaching.Add(1, 9);
            functionsWithCaching.Add(1, 10);
            functionsWithCaching.Add(1, 11);
            functionsWithCaching.Add(1, 1);

            Assert.Equal(12, functionsWithCaching.MethodExecutions);
        }