System.Data.Tests.DataRelationCollectionTest.Add C# (CSharp) Method

Add() private method

private Add ( ) : void
return void
        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();
        }