示例#1
0
      public void T060_PileNonOwnership()
      {
        var pile = new DefaultPile();
        pile.Start();
        try
        {
              var cache = new LocalCache();
              cache.Pile = pile;
              cache.Configure(null);
              cache.Start();
                
        
              var tA = cache.GetOrCreateTable<string>("A");
              tA.Put("aaa", "avalue");
              tA.Put("bbb", "bvalue");
              Assert.AreEqual("avalue", tA.Get("aaa"));

              Assert.AreEqual(2, cache.Count);
              Assert.AreEqual(2, pile.ObjectCount);

              cache.WaitForCompleteStop();
              Assert.AreEqual(NFX.ServiceModel.ControlStatus.Inactive, cache.Status);
        
              Assert.AreEqual(NFX.ServiceModel.ControlStatus.Active, pile.Status);
              Assert.AreEqual(0, pile.ObjectCount);
       
              cache = new LocalCache();
              cache.Pile = pile;
              cache.Configure(null);
              cache.Start();

              var tAbc = cache.GetOrCreateTable<string>("Abc");
              tAbc.Put("aaa", "avalue");
              tAbc.Put("bbb", "bvalue");
              tAbc.Put("ccc", "cvalue");
              tAbc.Put("ddd", "cvalue");

              Assert.AreEqual(4, pile.ObjectCount);

              var cache2 = new LocalCache();
              cache2.Pile = pile;
              cache2.Configure(null);
              cache2.Start();
                
        
              var t2 = cache2.GetOrCreateTable<string>("A");
              t2.Put("aaa", "avalue");
              t2.Put("bbb", "bvalue");
        
              Assert.AreEqual(2, cache2.Count);
              Assert.AreEqual(6, pile.ObjectCount);

              cache.WaitForCompleteStop();
              Assert.AreEqual(NFX.ServiceModel.ControlStatus.Active, pile.Status);
              Assert.AreEqual(2, pile.ObjectCount);

              cache2.WaitForCompleteStop();
              Assert.AreEqual(NFX.ServiceModel.ControlStatus.Active, pile.Status);
              Assert.AreEqual(0, pile.ObjectCount);

              pile.WaitForCompleteStop();
              Assert.AreEqual(NFX.ServiceModel.ControlStatus.Inactive, pile.Status);
        }
        finally
        {
          pile.Dispose();
        }
      }