public void BindingContext_Contains_NullDataSource_ThrowsArgumentNullException()
        {
            var context = new BindingContext();

            Assert.Throws <ArgumentNullException>("dataSource", () => context.Contains(null));
            Assert.Throws <ArgumentNullException>("dataSource", () => context.Contains(null, null));
            Assert.Throws <ArgumentNullException>("dataSource", () => context.Contains(null, string.Empty));
        }
Esempio n. 2
0
        public void CtorTest()
        {
            BindingContext bc = new BindingContext();

            Assert.IsFalse(bc.IsReadOnly, "CT1");
            Assert.IsFalse(bc.Contains(this), "CT2");
            Assert.IsFalse(bc.Contains(this, String.Empty), "CT3");
            Assert.IsFalse(bc.Contains(this, "Me is String"), "CT4");

            // Test the ICollection interface
            ICollection ic = (ICollection)bc;

            Assert.AreEqual(ic.Count, 0, "CT5");
            Assert.IsFalse(ic.IsSynchronized, "CT6");
            Assert.IsNull(ic.SyncRoot, "CT7");
            object [] arr = new object [] { "A", "B", "C" };
            ic.CopyTo(arr, 0);
            Assert.AreEqual(0, ic.Count, "CT8");
            Assert.IsFalse(ic.GetEnumerator().MoveNext(), "CT9");
        }
Esempio n. 3
0
        public void TestIndexerICurrencyManagerProvider()
        {
            BindingContext bc     = new BindingContext();
            BindingSource  source = new BindingSource();

            // This way the actual CurrencyManager instance is NOT added to
            // BindingContext
            CurrencyManager cm = (CurrencyManager)bc [source];

            Assert.AreSame(cm, source.CurrencyManager, "A1");
            Assert.AreEqual(false, bc.Contains(source), "A2");
            Assert.AreEqual(0, ((ICollection)bc).Count, "A3");
        }
        public void BindingContext_Contains_DataSource_ReturnsExpected()
        {
            var context    = new BindingContext();
            var source     = new BindingSource();
            var dataSource = new DataSource();

            context.Add(dataSource, source.CurrencyManager);
            Assert.True(context.Contains(dataSource));
            Assert.True(context.Contains(dataSource, null));
            Assert.True(context.Contains(dataSource, string.Empty));
            Assert.False(context.Contains(1));
            Assert.False(context.Contains(1, null));
            Assert.False(context.Contains(1, string.Empty));
        }
Esempio n. 5
0
 public void BindingContext_Contains_DataSource_ReturnsExpected(BindingContext context, object dataSource, bool expected)
 {
     Assert.Equal(expected, context.Contains(dataSource));
     Assert.Equal(expected, context.Contains(dataSource, null));
     Assert.Equal(expected, context.Contains(dataSource, string.Empty));
 }
Esempio n. 6
0
 public void BindingContext_Contains_DataSourceDataMember_ReturnsExpected(BindingContext context, object dataSource, string dataMember, bool expected)
 {
     Assert.Equal(expected, context.Contains(dataSource, dataMember));
 }