Пример #1
0
		public void TestPrivatePools()
		{
			SymbolPool p1 = new SymbolPool();
			SymbolPool p2 = new SymbolPool(3);
			SymbolPool p3 = new SymbolPool(0);
			Symbol a = GSymbol.Get("a");
			Symbol b = GSymbol.Get("b");
			Symbol c = GSymbol.Get("c");
			Symbol s1a = p1.Get("a");
			Symbol s1b = p1.Get("b");
			Symbol s1c = p1.Get("c");
			Symbol s2a = p2.Get("a");
			Symbol s3a = p3.Get("a");
			Symbol s3b = p3.Get("b");

			Assert.That(s1a.Id == 1 && p1.GetById(1) == s1a);
			Assert.That(s1b.Id == 2 && p1.GetById(2) == s1b);
			Assert.That(s1c.Id == 3 && p1.GetById(3) == s1c);
			Assert.That(s2a.Id == 3 && p2.GetById(3) == s2a);
			Assert.That(s3b.Id == 1 && p3.GetById(1) == s3b);
			Assert.That(s3a.Id == 0 && p3.GetById(0) == s3a);
			Assert.AreEqual(GSymbol.Empty, p1.GetById(0));
			Assert.AreEqual(s1c, p1.GetIfExists("c"));
			Assert.AreEqual(3, p1.TotalCount);
			Assert.AreEqual(null, p2.GetIfExists("c"));
			Assert.AreEqual(c, p2.GetGlobalOrCreateHere("c"));
			Assert.AreEqual(p2, p2.GetGlobalOrCreateHere("$!unique^&*").Pool);
		}
Пример #2
0
        public void TestPrivatePools()
        {
            SymbolPool p1  = new SymbolPool();
            SymbolPool p2  = new SymbolPool(3);
            SymbolPool p3  = new SymbolPool(0);
            Symbol     a   = GSymbol.Get("a");
            Symbol     b   = GSymbol.Get("b");
            Symbol     c   = GSymbol.Get("c");
            Symbol     s1a = p1.Get("a");
            Symbol     s1b = p1.Get("b");
            Symbol     s1c = p1.Get("c");
            Symbol     s2a = p2.Get("a");
            Symbol     s3a = p3.Get("a");
            Symbol     s3b = p3.Get("b");

            Assert.That(s1a.Id == 1 && p1.GetById(1) == s1a);
            Assert.That(s1b.Id == 2 && p1.GetById(2) == s1b);
            Assert.That(s1c.Id == 3 && p1.GetById(3) == s1c);
            Assert.That(s2a.Id == 3 && p2.GetById(3) == s2a);
            Assert.That(s3b.Id == 1 && p3.GetById(1) == s3b);
            Assert.That(s3a.Id == 0 && p3.GetById(0) == s3a);
            Assert.AreEqual(GSymbol.Empty, p1.GetById(0));
            Assert.AreEqual(s1c, p1.GetIfExists("c"));
            Assert.AreEqual(3, p1.TotalCount);
            Assert.AreEqual(null, p2.GetIfExists("c"));
            //Assert.AreEqual(c, p2.GetGlobalOrCreateHere("c"));
            //Assert.AreEqual(p2, p2.GetGlobalOrCreateHere("$!unique^&*").Pool);
        }
 /// <summary>
 /// Get the exception with the given name.
 /// This is an alias to Pool.Get(string).
 /// </summary>
 /// <param name="name">Name of the symbol.</param>
 /// <returns>The Exceptions symbol.</returns>
 public static Exceptions Get(string name)
 {
     return(Pool.Get(name));
 }