Exemple #1
0
        public void BagWrapper()
        {
            var holder = new BagHolder();
            var bag    = holder.Bag;

            Assert.AreEqual(0, bag.Count);
            // This is the critical test: the wrapper should see the modifications to the original.
            holder.Add(1);
            Assert.AreEqual(1, bag.Count);
            // Pause to make sure all the interface functions work.
            Assert.AreEqual(1, bag.Occurrences(1));
            Assert.AreEqual(1, bag.Items.Count());
            holder.Add(2);             // moves it up to set
            Assert.AreEqual(2, bag.Count);
            var list = new List <int>(bag);

            list.Sort();
            Assert.AreEqual(1, list[0]);
            Assert.AreEqual(2, list[1]);
            holder.Add(1);             // moves it to dictionary
            Assert.AreEqual(2, bag.Occurrences(1));
        }
Exemple #2
0
		public void BagWrapper()
		{
			var holder = new BagHolder();
			var bag = holder.Bag;
			Assert.AreEqual(0, bag.Count);
			// This is the critical test: the wrapper should see the modifications to the original.
			holder.Add(1);
			Assert.AreEqual(1, bag.Count);
			// Pause to make sure all the interface functions work.
			Assert.AreEqual(1, bag.Occurrences(1));
			Assert.AreEqual(1, bag.Items.Count());
			holder.Add(2); // moves it up to set
			Assert.AreEqual(2, bag.Count);
			var list = new List<int>(bag);
			list.Sort();
			Assert.AreEqual(1, list[0]);
			Assert.AreEqual(2, list[1]);
			holder.Add(1); // moves it to dictionary
			Assert.AreEqual(2, bag.Occurrences(1));
		}