Esempio n. 1
0
 public void KeyComposition()
 {
     Key k1 = "test";
     KeyPrefix p1 = new KeyPrefix("tenant", "region");
     CacheKey cc = new CacheKey(p1, k1);
     Assert.True(cc.Prefix.Tenant == "tenant" && cc.Prefix.Region == "region" && cc.Suffix == "test");
     CacheKey newcc = cc;
     Assert.True(newcc == cc);
 }
Esempio n. 2
0
 public void Affectation()
 {
     Key k1 = "ppppp";
     KeyPrefix p1 = new KeyPrefix(Key.Null, "1651651645621");
     CacheKey cc = new CacheKey(p1, k1);
     CacheKey affected = cc;
     Assert.True(cc == affected);
     var kv = new KeyValuePair<CacheKey, object>(affected, null);
     Assert.Equal(cc, kv.Key);
 }
Esempio n. 3
0
        public async Task PutGetStringRegionKeyValueAsync()
        {
            KeyPrefix prefix = new KeyPrefix(Key.Null, _keyString);
            Dictionary<CacheKey, string> dictionary = Enumerable.Range(0, 100)
                .ToDictionary(i => new CacheKey(prefix, i.ToString()), i => _dataString + i.ToString());
            this._cache1.PutRegion(dictionary.ToArray());

            var fetched = await this._cache2.GetRegionKeyValuesAsync<string>(prefix);
            Assert.Equal(dictionary.Count(), fetched.Count());
            foreach (var kv in fetched)
            {
                Assert.Equal(dictionary[kv.Key], kv.Value);
            }
        }
Esempio n. 4
0
        public async Task PutGetStringRegionAsync()
        {
            KeyPrefix prefix = new KeyPrefix(Key.Null, _keyString);

            Dictionary<CacheKey, Serialized> dictionary = Enumerable.Range(0, 100)
                .ToDictionary(i => new CacheKey(prefix, i.ToString()),
                    i => new Serialized { Id = i, Property = _dataString + i.ToString() });

            this._cache1.PutRegion(dictionary.ToArray());
            Func<Serialized, CacheKey> funk = s => new CacheKey(prefix, s.Id.ToString());
            IEnumerable<Serialized> result = await this._cache2.GetRegionAsync(prefix, funk);
            var fetched = result.ToDictionary(funk);
            Assert.Equal(dictionary.Count(), fetched.Count());
            foreach (var kv in fetched)
            {
                Assert.Equal(dictionary[kv.Key].Property, kv.Value.Property);
            }
        }
Esempio n. 5
0
        public async Task PutGetSerializedRegionAsync()
        {
            KeyPrefix prefix = new KeyPrefix(Key.Null, _keyString);

            Dictionary<CacheKey, Serialized> dictionary = Enumerable.Range(0, 100)
                .ToDictionary(i => new CacheKey(prefix, i.ToString()),
                    i => new Serialized { Property = _dataString + i.ToString() });

            this._cache1.PutRegion(dictionary.ToArray());
            var fetched = await this._cache2.GetRegionKeyValuesAsync<Serialized>(prefix);
            Assert.Equal(dictionary.Count(), fetched.Count());
            foreach (var kv in fetched)
            {
                if (kv.Key.Suffix == "57")
                {
                    ;
                }
                Assert.Equal(dictionary[kv.Key].Property, kv.Value.Property);
            }
        }
Esempio n. 6
0
 public void KeyPrefixTranstypeString()
 {
     KeyPrefix p1 = new KeyPrefix("test", Key.Null);
     Assert.True(p1.Tenant == "test");
 }
Esempio n. 7
0
 public void KeyPrefixTenantTranstypeString()
 {
     KeyPrefix p1 = new KeyPrefix("tenant", "test");
     Assert.True(p1.Tenant == "tenant" && p1.Region == "test");
 }
Esempio n. 8
0
 public async Task CanRemoveRegion()
 {
     KeyPrefix prefix = new KeyPrefix(Key.Null, _keyString);
     Dictionary<CacheKey, string> dictionary = Enumerable.Range(0, 100)
         .ToDictionary(i => new CacheKey(prefix, i.ToString()), i => _dataString + i.ToString());
     this._cache.PutRegion(dictionary.ToArray());
     var fetched = await this._cache.GetRegionKeyValuesAsync<string>(prefix);
     Assert.Equal(dictionary.Count(), fetched.Count());
     this._cache.RemoveRegion(prefix);
     IEnumerable<KeyValuePair<CacheKey, Serialized>> removed = await this._cache.GetRegionKeyValuesAsync<Serialized>(prefix);
     Assert.Empty(removed);
 }