Exemplo n.º 1
0
        public void Add()
        {
            DataRelationCollection drcol     = _dataset.Relations;
            DataColumn             parentCol = _dataset.Tables["Customer"].Columns["custid"];
            DataColumn             childCol  = _dataset.Tables["Order"].Columns["custid"];
            DataRelation           dr        = new DataRelation("CustOrder", parentCol, childCol);

            drcol.Add(dr);
            Assert.Equal("CustOrder", drcol[0].RelationName);
            drcol.Clear();

            drcol.Add(parentCol, childCol);
            Assert.Equal(1, drcol.Count);
            drcol.Clear();

            drcol.Add("NewRelation", parentCol, childCol);
            Assert.Equal("NewRelation", drcol[0].RelationName);
            drcol.Clear();

            drcol.Add("NewRelation", parentCol, childCol, false);
            Assert.Equal(1, drcol.Count);
            drcol.Clear();

            drcol.Add("NewRelation", parentCol, childCol, true);
            Assert.Equal(1, drcol.Count);
            drcol.Clear();
        }
        public void Add()
        {
            DataRelationCollection drcol     = _dataset.Relations;
            DataColumn             parentCol = _dataset.Tables ["Customer"].Columns ["custid"];
            DataColumn             childCol  = _dataset.Tables ["Order"].Columns ["custid"];
            DataRelation           dr        = new DataRelation("CustOrder", parentCol, childCol);

            drcol.Add(dr);
            Assert.That(drcol [0].RelationName, Is.EqualTo("CustOrder"), "test#1");
            drcol.Clear();

            drcol.Add(parentCol, childCol);
            Assert.That(drcol.Count, Is.EqualTo(1), "test#2");
            drcol.Clear();

            drcol.Add("NewRelation", parentCol, childCol);
            Assert.That(drcol [0].RelationName, Is.EqualTo("NewRelation"), "test#3");
            drcol.Clear();

            drcol.Add("NewRelation", parentCol, childCol, false);
            Assert.That(drcol.Count, Is.EqualTo(1), "test#4");
            drcol.Clear();

            drcol.Add("NewRelation", parentCol, childCol, true);
            Assert.That(drcol.Count, Is.EqualTo(1), "test#5");
            drcol.Clear();
        }
Exemplo n.º 3
0
        public void Clear()
        {
            DataRelationCollection drcol     = _dataset.Relations;
            DataColumn             parentCol = _dataset.Tables["Customer"].Columns["custid"];
            DataColumn             childCol  = _dataset.Tables["Order"].Columns["custid"];

            drcol.Add(new DataRelation("CustOrder", parentCol, childCol));
            drcol.Add("ItemOrder", _dataset.Tables["Item"].Columns["itemid"]
                      , _dataset.Tables["Order"].Columns["itemid"]);
            drcol.Clear();
            Assert.Equal(0, drcol.Count);
        }