コード例 #1
0
        public void Add()
        {
            BindingContextPoker p = new BindingContextPoker();
            object data_source    = new object();

            p.collection_changed = -1;
            Assert.IsFalse(p.Contains(data_source), "ADD1");
            Assert.AreEqual(0, ((ICollection)p).Count, "ADD2");
            p._Add(data_source, new PropertyManager());
            Assert.IsTrue(p.Contains(data_source), "ADD3");
            Assert.AreEqual(1, ((ICollection)p).Count, "ADD4");
            Assert.AreEqual(p.collection_changed, (int)CollectionChangeAction.Add, "ADD5");

            p.collection_changed = -1;
            p._Add(data_source, new PropertyManager());
            Assert.IsTrue(p.Contains(data_source), "ADD6");
            Assert.AreEqual(1, ((ICollection)p).Count, "ADD7");
            Assert.AreEqual(p.collection_changed, (int)CollectionChangeAction.Add, "ADD8");

            p.collection_changed = -1;
            data_source          = new object();
            p._Add(data_source, new PropertyManager());
            Assert.IsTrue(p.Contains(data_source), "ADD9");
            Assert.AreEqual(2, ((ICollection)p).Count, "ADD10");
            Assert.AreEqual(p.collection_changed, (int)CollectionChangeAction.Add, "ADD9");
        }
コード例 #2
0
        public void TestContainsNull2()
        {
            BindingContextPoker p = new BindingContextPoker();
            object data_source    = new object();

            p._Add(data_source, new PropertyManager());
            Assert.IsTrue(p.Contains(data_source, null), "#1");
            Assert.IsFalse(p.Contains("nonexistent", null), "#2");
        }
コード例 #3
0
        public void TestGetEnumerator()
        {
            BindingContextPoker p       = new BindingContextPoker();
            object          data_source = new object();
            PropertyManager pm          = new PropertyManager();

            p._Add(data_source, pm);
            IEnumerator e = ((IEnumerable)p).GetEnumerator();

            Assert.IsNotNull(e, "#1");
            IDictionaryEnumerator de = e as IDictionaryEnumerator;

            Assert.IsNotNull(de, "#2");
            Assert.IsTrue(de.MoveNext(), "#3");
            // In .NET Key is its internal type.
            //Assert.AreEqual (data_source, de.Key, "#4");
            //Assert.AreEqual (pm, de.Value, "#5");
            Assert.IsFalse(de.MoveNext(), "#6");
        }
コード例 #4
0
        public void ClearCore()
        {
            BindingContextPoker p = new BindingContextPoker();
            object data_source    = new object();

            p._Add(data_source, new PropertyManager());
            p.collection_changed = -1;
            p._Clear();
            Assert.IsFalse(p.Contains(data_source), "CLEARCORE1");
            Assert.AreEqual(0, ((ICollection)p).Count, "CLEARCORE2");
            Assert.AreEqual(p.collection_changed, (int)CollectionChangeAction.Refresh, "CLEARCORE3");

            // Double clear
            p.collection_changed = -1;
            p._Clear();
            Assert.IsFalse(p.Contains(data_source), "CLEARCORE4");
            Assert.AreEqual(0, ((ICollection)p).Count, "CLEARCORE5");
            Assert.AreEqual(p.collection_changed, (int)CollectionChangeAction.Refresh, "CLEARCORE6");
        }
コード例 #5
0
        public void Remove()
        {
            BindingContextPoker p = new BindingContextPoker();
            object data_source    = new object();

            p.collection_changed = -1;
            p._Add(data_source, new PropertyManager());
            Assert.IsTrue(p.Contains(data_source), "REMOVE1");
            Assert.AreEqual(1, ((ICollection)p).Count, "REMOVE2");
            Assert.AreEqual(p.collection_changed, (int)CollectionChangeAction.Add, "REMOVE3");
            p._Remove(data_source);
            Assert.IsFalse(p.Contains(data_source), "REMOVE4");
            Assert.AreEqual(0, ((ICollection)p).Count, "REMOVE5");
            Assert.AreEqual(p.collection_changed, (int)CollectionChangeAction.Remove, "REMOVE6");

            // Double remove
            p.collection_changed = -1;
            p._Remove(data_source);
            Assert.IsFalse(p.Contains(data_source), "REMOVE7");
            Assert.AreEqual(0, ((ICollection)p).Count, "REMOVE8");
            Assert.AreEqual(p.collection_changed, (int)CollectionChangeAction.Remove, "REMOVE9");
        }
コード例 #6
0
        public void AddNullDataSource()
        {
            BindingContextPoker p = new BindingContextPoker();

            p._Add(null, new PropertyManager());
        }
コード例 #7
0
        public void AddNullListManager()
        {
            BindingContextPoker p = new BindingContextPoker();

            p._Add(new object(), null);
        }
コード例 #8
0
ファイル: BindingContextTest.cs プロジェクト: Profit0004/mono
		public void TestContainsNull2 ()
		{
			BindingContextPoker p = new BindingContextPoker ();
			object data_source = new object ();
			p._Add (data_source, new PropertyManager ());
			Assert.IsTrue (p.Contains (data_source, null), "#1");
			Assert.IsFalse (p.Contains ("nonexistent", null), "#2");
		}
コード例 #9
0
ファイル: BindingContextTest.cs プロジェクト: Profit0004/mono
		public void TestGetEnumerator ()
		{
			BindingContextPoker p = new BindingContextPoker ();
			object data_source = new object ();
			PropertyManager pm = new PropertyManager ();
			p._Add (data_source, pm);
			IEnumerator e = ((IEnumerable) p).GetEnumerator ();
			Assert.IsNotNull (e, "#1");
			IDictionaryEnumerator de = e as IDictionaryEnumerator;
			Assert.IsNotNull (de, "#2");
			Assert.IsTrue (de.MoveNext (), "#3");
			// In .NET Key is its internal type.
			//Assert.AreEqual (data_source, de.Key, "#4");
			//Assert.AreEqual (pm, de.Value, "#5");
			Assert.IsFalse (de.MoveNext (), "#6");
		}
コード例 #10
0
ファイル: BindingContextTest.cs プロジェクト: Profit0004/mono
		public void ClearCore ()
		{
			BindingContextPoker p = new BindingContextPoker ();
			object data_source = new object ();

			p._Add (data_source, new PropertyManager ());
			p.collection_changed = -1;
			p._Clear ();
			Assert.IsFalse (p.Contains (data_source), "CLEARCORE1");
			Assert.AreEqual (0, ((ICollection) p).Count, "CLEARCORE2");
			Assert.AreEqual (p.collection_changed, (int) CollectionChangeAction.Refresh, "CLEARCORE3");

			// Double clear
			p.collection_changed = -1;
			p._Clear ();
			Assert.IsFalse (p.Contains (data_source), "CLEARCORE4");
			Assert.AreEqual (0, ((ICollection) p).Count, "CLEARCORE5");
			Assert.AreEqual (p.collection_changed, (int) CollectionChangeAction.Refresh, "CLEARCORE6");
		}
コード例 #11
0
ファイル: BindingContextTest.cs プロジェクト: Profit0004/mono
		public void RemoveCore ()
		{
			BindingContextPoker p = new BindingContextPoker ();
			object data_source = new object ();

			p.collection_changed = -1;
			p._Add (data_source, new PropertyManager ());
			Assert.IsTrue (p.Contains (data_source), "REMOVECORE1");
			Assert.AreEqual (1, ((ICollection) p).Count, "REMOVECORE2");
			Assert.AreEqual (p.collection_changed, (int) CollectionChangeAction.Add, "REMOVECORE3");

			p.collection_changed = -1;
			p._RemoveCore (data_source);
			Assert.IsFalse (p.Contains (data_source), "REMOVECORE4");
			Assert.AreEqual (0, ((ICollection) p).Count, "REMOVECORE5");
			Assert.AreEqual (p.collection_changed, -1, "REMOVECORE6");

			// Double remove
			p.collection_changed = -1;
			p._Remove (data_source);
			Assert.IsFalse (p.Contains (data_source), "REMOVECORE7");
			Assert.AreEqual (0, ((ICollection) p).Count, "REMOVECORE8");
			Assert.AreEqual (p.collection_changed, (int) CollectionChangeAction.Remove, "REMOVECORE9");
		}
コード例 #12
0
ファイル: BindingContextTest.cs プロジェクト: Profit0004/mono
		public void Add ()
		{
			BindingContextPoker p = new BindingContextPoker ();
			object data_source = new object ();

			p.collection_changed = -1;
			Assert.IsFalse (p.Contains (data_source), "ADD1");
			Assert.AreEqual (0, ((ICollection) p).Count, "ADD2");
			p._Add (data_source, new PropertyManager ());
			Assert.IsTrue (p.Contains (data_source), "ADD3");
			Assert.AreEqual (1, ((ICollection) p).Count, "ADD4");
			Assert.AreEqual (p.collection_changed, (int) CollectionChangeAction.Add, "ADD5");

			p.collection_changed = -1;
			p._Add (data_source, new PropertyManager ());
			Assert.IsTrue (p.Contains (data_source), "ADD6");
			Assert.AreEqual (1, ((ICollection) p).Count, "ADD7");
			Assert.AreEqual (p.collection_changed, (int) CollectionChangeAction.Add, "ADD8");

			p.collection_changed = -1;
			data_source = new object ();
			p._Add (data_source, new PropertyManager ());
			Assert.IsTrue (p.Contains (data_source), "ADD9");
			Assert.AreEqual (2, ((ICollection) p).Count, "ADD10");
			Assert.AreEqual (p.collection_changed, (int) CollectionChangeAction.Add, "ADD9");
		}
コード例 #13
0
ファイル: BindingContextTest.cs プロジェクト: Profit0004/mono
		public void AddNullListManager ()
		{
			BindingContextPoker p = new BindingContextPoker ();

			p._Add (new object (), null);
		}
コード例 #14
0
ファイル: BindingContextTest.cs プロジェクト: Profit0004/mono
		public void AddNullDataSource ()
		{
			BindingContextPoker p = new BindingContextPoker ();

			p._Add (null, new PropertyManager ());
		}