public void TestCapacity()
        {
            ConnectionCache cache = new ConnectionCache();

            for (int i = 0; i < ConnectionCache.CAPACITY; i++)
            {
                cache.AddToCache(GetConnectionInfo(i));
                Assert.AreEqual(i + 1, cache.GetCachedConnections().Count());
            }

            // add one more over capacity
            cache.AddToCache(GetConnectionInfo(ConnectionCache.CAPACITY));
            Assert.AreEqual(ConnectionCache.CAPACITY, cache.GetCachedConnections().Count());
        }
        public void Ctor_ConfigStringIsValidJson_CacheIsCorrect()
        {
            ConnectionCache cache       = new ConnectionCache(KnownConfigString);
            List <Uri>      connections = cache.GetCachedConnections().ToList();

            Assert.AreEqual(2, connections.Count);

            ConnectionInfo info1 = GetConnectionInfo(1, true);
            ConnectionInfo info2 = GetConnectionInfo(2, true);

            CompareConnectionInfos(info1, cache.GetMostRecentConnection(info1.ServerUri));
            CompareConnectionInfos(info2, cache.GetMostRecentConnection(info2.ServerUri));
        }
        public void Ctor_ConfigStringIsInvalidJson_CacheIsEmpty()
        {
            ConnectionCache cache = new ConnectionCache("This isn't valid Json");

            Assert.IsFalse(cache.GetCachedConnections().Any());
        }
        public void Ctor_ConfigStringIsTrivial_CacheIsEmpty()
        {
            ConnectionCache cache = new ConnectionCache(null);

            Assert.AreEqual(0, cache.GetCachedConnections().Count());
        }