Пример #1
0
		public void CreateAdminNode()
		{
			IObjectSet s = new ObjectSet();
			this.m_data.Add("admin", s);
		}
Пример #2
0
		public void TestObjectSet()
		{
			IPoolable r = null;
			var tt11 = this.InitlizeTestTarget1();
			var tt12 = this.InitlizeTestTarget1();
			var tt13 = this.InitlizeTestTarget1();

			///
			/// new
			///
			ObjectSet set = new ObjectSet(); Assert.AreEqual(set.Count, 0);

			///
			/// set
			///
			set.Set(tt11);
			Assert.AreEqual(set.Count, 1);

			set.Set(tt12);
			Assert.AreEqual(set.Count, 2);

			set.Set(tt12);
			Assert.AreEqual(set.Count, 2);

			///
			/// Get
			///
			r = set.Get();
			Assert.AreEqual(r.ToString(), tt11.ToString());
			Assert.AreEqual(set.Count, 1);
			Assert.AreSame(r, tt11);
			r = set.Get();
			Assert.AreEqual(r.ToString(), tt12.ToString());
			Assert.AreEqual(set.Count, 0);
			Assert.AreSame(r, tt12);

			r = set.Get();
			Assert.IsNull(r);
			Assert.AreEqual(set.Count, 0);

			///
			/// Remove1
			///
			set.Set(tt11);
			Assert.AreEqual(set.Count, 1);

			set.Set(tt12);
			Assert.AreEqual(set.Count, 2);

			set.Remove(tt12);
			Assert.AreEqual(set.Count, 1);

			r = set.Get();
			Assert.AreEqual(r.ToString(), tt11.ToString());
			Assert.AreEqual(set.Count, 0);
			Assert.AreSame(r, tt11);

			///
			/// Remove2
			///
			set.Set(tt12);
			Assert.AreEqual(set.Count, 1);

			set.Remove(tt13);
			Assert.AreEqual(set.Count, 1);

			set.Remove(tt12);
			Assert.AreEqual(set.Count, 0);

			set.Remove(tt11);
			Assert.AreEqual(set.Count, 0);

			///
			/// Clear
			///
			set.Set(tt12);
			Assert.AreEqual(set.Count, 1);

			set.Set(tt13);
			Assert.AreEqual(set.Count, 2);

			set.Clear();
			Assert.AreEqual(set.Count, 0);
		}