Пример #1
0
        public void TestNamedCache3()
        {
            Assert.AreEqual(0, cache2.Hits);
            Assert.AreEqual(0, cache2.Misses);

            var service = new Service2();
            IEnumerable <string> result;

            result = service.MethodToCache1(2.0);
            Assert.AreEqual(0, cache2.Hits);
            Assert.AreEqual(2, cache2.Misses);
            CollectionAssert.AreEqual(new[] { "0.9", "1.9" }, result.ToArray());

            result = service.MethodToCache1(2.0);
            Assert.AreEqual(1, cache2.Hits);
            Assert.AreEqual(2, cache2.Misses);
            CollectionAssert.AreEqual(new[] { "0.9", "1.9" }, result.ToArray());

            result = service.MethodToCache1(2);
            Assert.AreEqual(1, cache2.Hits);
            Assert.AreEqual(4, cache2.Misses);
            CollectionAssert.AreEqual(new[] { "1", "2" }, result.ToArray());

            result = service.MethodToCache1(2);
            Assert.AreEqual(2, cache2.Hits);
            Assert.AreEqual(4, cache2.Misses);
            CollectionAssert.AreEqual(new[] { "1", "2" }, result.ToArray());
        }
Пример #2
0
        public void TestNamedCache2()
        {
            var service = new Service2();
            var result  = service.MethodToCache1(2);

            CollectionAssert.AreEqual(new[] { "1", "2" }, result.ToArray());
            CollectionAssert.AreEqual(new[] { "1", "2" }, result.ToArray());
        }
Пример #3
0
        public void TestNamedCache2()
        {
            var service = new Service2();
            var result  = service.MethodToCache1(2);

            LinqAssert.AreSame(new [] { "1", "2" }, result);
            LinqAssert.AreSame(new[] { "1", "2" }, result);
        }
Пример #4
0
        public void TestNamedCache1()
        {
            Assert.AreEqual(0, cache2.Hits);
            Assert.AreEqual(0, cache2.Misses);

            var service = new Service2();
            var result  = service.MethodToCache1();

            Assert.AreEqual(0, cache2.Hits);
            Assert.AreEqual(2, cache2.Misses);
        }