public void Remove() { DataRelationCollection drcol = _dataset.Relations; DataRelation dr1 = new DataRelation("CustOrder" , _dataset.Tables["Customer"].Columns["custid"] , _dataset.Tables["Order"].Columns["custid"]); DataRelation dr2 = new DataRelation("ItemOrder" , _dataset.Tables["Item"].Columns["itemid"] , _dataset.Tables["Order"].Columns["custid"]); drcol.Add(dr1); drcol.Add(dr2); drcol.Remove(dr1); Assert.False(drcol.Contains(dr1.RelationName)); drcol.Add(dr1); drcol.Remove("CustOrder"); Assert.False(drcol.Contains("CustOrder")); drcol.Add(dr1); DataRelation drnull = null; drcol.Remove(drnull); DataRelation newdr = new DataRelation("newdr" , _dataset.Tables["Customer"].Columns["custid"] , _dataset.Tables["Order"].Columns["custid"]); AssertExtensions.Throws <ArgumentException>(null, () => drcol.Remove(newdr)); }
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(); }
public void IndexOf() { DataRelationCollection drcol = _dataset.Relations; DataRelation dr1 = new DataRelation("CustOrder" , _dataset.Tables["Customer"].Columns["custid"] , _dataset.Tables["Order"].Columns["custid"]); DataRelation dr2 = new DataRelation("ItemOrder" , _dataset.Tables["Item"].Columns["itemid"] , _dataset.Tables["Order"].Columns["custid"]); drcol.Add(dr1); drcol.Add(dr2); Assert.Equal(0, drcol.IndexOf(dr1)); Assert.Equal(1, drcol.IndexOf(dr2)); Assert.Equal(0, drcol.IndexOf("CustOrder")); Assert.Equal(1, drcol.IndexOf("ItemOrder")); Assert.Equal(0, drcol.IndexOf(drcol[0])); Assert.Equal(1, drcol.IndexOf(drcol[1])); Assert.Equal(-1, drcol.IndexOf("_noRelation_")); DataRelation newdr = new DataRelation("newdr" , _dataset.Tables["Customer"].Columns["custid"] , _dataset.Tables["Order"].Columns["custid"]); Assert.Equal(-1, drcol.IndexOf(newdr)); }
public void RemoveAt() { DataRelationCollection drcol = _dataset.Relations; DataRelation dr1 = new DataRelation("CustOrder" , _dataset.Tables["Customer"].Columns["custid"] , _dataset.Tables["Order"].Columns["custid"]); DataRelation dr2 = new DataRelation("ItemOrder" , _dataset.Tables["Item"].Columns["itemid"] , _dataset.Tables["Order"].Columns["custid"]); drcol.Add(dr1); drcol.Add(dr2); try { drcol.RemoveAt(-1); Assert.False(true); } catch (IndexOutOfRangeException e) { } try { drcol.RemoveAt(101); Assert.False(true); } catch (IndexOutOfRangeException e) { } drcol.RemoveAt(1); Assert.False(drcol.Contains(dr2.RelationName)); drcol.RemoveAt(0); Assert.False(drcol.Contains(dr1.RelationName)); }
public void IndexOf() { DataRelationCollection drcol = _dataset.Relations; DataRelation dr1 = new DataRelation("CustOrder" , _dataset.Tables["Customer"].Columns["custid"] , _dataset.Tables["Order"].Columns["custid"]); DataRelation dr2 = new DataRelation("ItemOrder" , _dataset.Tables["Item"].Columns["itemid"] , _dataset.Tables["Order"].Columns["custid"]); drcol.Add(dr1); drcol.Add(dr2); AssertEquals("test#1", 0, drcol.IndexOf(dr1)); AssertEquals("test#2", 1, drcol.IndexOf(dr2)); AssertEquals("test#3", 0, drcol.IndexOf("CustOrder")); AssertEquals("test#4", 1, drcol.IndexOf("ItemOrder")); AssertEquals("test#5", 0, drcol.IndexOf(drcol[0])); AssertEquals("test#6", 1, drcol.IndexOf(drcol[1])); AssertEquals("test#7", -1, drcol.IndexOf("_noRelation_")); DataRelation newdr = new DataRelation("newdr" , _dataset.Tables["Customer"].Columns["custid"] , _dataset.Tables["Order"].Columns["custid"]); AssertEquals("test#8", -1, drcol.IndexOf(newdr)); }
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 IndexOf() { DataRelationCollection drcol = _dataset.Relations; DataRelation dr1 = new DataRelation("CustOrder" , _dataset.Tables ["Customer"].Columns ["custid"] , _dataset.Tables ["Order"].Columns ["custid"]); DataRelation dr2 = new DataRelation("ItemOrder" , _dataset.Tables ["Item"].Columns ["itemid"] , _dataset.Tables ["Order"].Columns ["custid"]); drcol.Add(dr1); drcol.Add(dr2); Assert.That(drcol.IndexOf(dr1), Is.EqualTo(0), "test#1"); Assert.That(drcol.IndexOf(dr2), Is.EqualTo(1), "test#2"); Assert.That(drcol.IndexOf("CustOrder"), Is.EqualTo(0), "test#3"); Assert.That(drcol.IndexOf("ItemOrder"), Is.EqualTo(1), "test#4"); Assert.That(drcol.IndexOf(drcol [0]), Is.EqualTo(0), "test#5"); Assert.That(drcol.IndexOf(drcol [1]), Is.EqualTo(1), "test#6"); Assert.That(drcol.IndexOf("_noRelation_"), Is.EqualTo(-1), "test#7"); DataRelation newdr = new DataRelation("newdr" , _dataset.Tables ["Customer"].Columns ["custid"] , _dataset.Tables ["Order"].Columns ["custid"]); Assert.That(drcol.IndexOf(newdr), Is.EqualTo(-1), "test#8"); }
public void RemoveAt() { DataRelationCollection drcol = _dataset.Relations; DataRelation dr1 = new DataRelation("CustOrder" , _dataset.Tables ["Customer"].Columns ["custid"] , _dataset.Tables ["Order"].Columns ["custid"]); DataRelation dr2 = new DataRelation("ItemOrder" , _dataset.Tables ["Item"].Columns ["itemid"] , _dataset.Tables ["Order"].Columns ["custid"]); drcol.Add(dr1); drcol.Add(dr2); try { drcol.RemoveAt(-1); Assert.Fail("the index was out of bound: must have failed"); } catch (IndexOutOfRangeException e) { } try { drcol.RemoveAt(101); Assert.Fail("the index was out of bound: must have failed"); } catch (IndexOutOfRangeException e) { } drcol.RemoveAt(1); Assert.That(drcol.Contains(dr2.RelationName), Is.False, "test#5"); drcol.RemoveAt(0); Assert.That(drcol.Contains(dr1.RelationName), Is.False, "test#6"); }
public void AddException2() { DataRelationCollection drcol = _dataset.Relations; DataRelation dr1 = new DataRelation("CustOrder" , _dataset.Tables ["Customer"].Columns ["custid"] , _dataset.Tables ["Order"].Columns ["custid"]); drcol.Add(dr1); drcol.Add(dr1); }
public void AddException2() { AssertExtensions.Throws <ArgumentException>(null, () => { DataRelationCollection drcol = _dataset.Relations; DataRelation dr1 = new DataRelation("CustOrder" , _dataset.Tables["Customer"].Columns["custid"] , _dataset.Tables["Order"].Columns["custid"]); drcol.Add(dr1); drcol.Add(dr1); }); }
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); }
public void AddException3() { DataRelationCollection drcol = _dataset.Relations; DataRelation dr1 = new DataRelation("DuplicateName" , _dataset.Tables ["Customer"].Columns ["custid"] , _dataset.Tables ["Order"].Columns ["custid"]); DataRelation dr2 = new DataRelation("DuplicateName" , _dataset.Tables ["Item"].Columns ["itemid"] , _dataset.Tables ["Order"].Columns ["custid"]); drcol.Add(dr1); drcol.Add(dr2); }
public void AddException1() { DataRelationCollection drcol = _dataset.Relations; DataRelation drnull = null; drcol.Add(drnull); }
public void Remove() { DataRelationCollection drcol = _dataset.Relations; DataRelation dr1 = new DataRelation("CustOrder" , _dataset.Tables["Customer"].Columns["custid"] , _dataset.Tables["Order"].Columns["custid"]); DataRelation dr2 = new DataRelation("ItemOrder" , _dataset.Tables["Item"].Columns["itemid"] , _dataset.Tables["Order"].Columns["custid"]); drcol.Add(dr1); drcol.Add(dr2); drcol.Remove(dr1); AssertEquals("test#1", false, drcol.Contains(dr1.RelationName)); drcol.Add(dr1); drcol.Remove("CustOrder"); AssertEquals("test#2", false, drcol.Contains("CustOrder")); drcol.Add(dr1); DataRelation drnull = null; drcol.Remove(drnull); DataRelation newdr = new DataRelation("newdr" , _dataset.Tables["Customer"].Columns["custid"] , _dataset.Tables["Order"].Columns["custid"]); try { drcol.Remove(newdr); Fail("Err: removed relation which not part of collection"); } catch (Exception e) { AssertEquals("test#4", typeof(ArgumentException), e.GetType()); } try { drcol.Remove("newdr"); Fail("Err: removed relation which not part of collection"); } catch (ArgumentException e) { } }
public void Equals() { DataRelationCollection drcol = _dataset.Relations; drcol.Add("CustOrder" , _dataset.Tables["Customer"].Columns["custid"] , _dataset.Tables["Order"].Columns["custid"]); drcol.Add("ItemOrder" , _dataset.Tables["Item"].Columns["itemid"] , _dataset.Tables["Order"].Columns["custid"]); DataSet newds = new DataSet(); DataRelationCollection drcol1 = newds.Relations; DataRelationCollection drcol2 = _dataset.Relations; Assert.Same(drcol, drcol2); Assert.NotSame(drcol1, drcol); }
//[Test] public void ToStringTest() { DataRelationCollection drcol = _dataset.Relations; DataRelation dr1 = new DataRelation("CustOrder" , _dataset.Tables ["Customer"].Columns ["custid"] , _dataset.Tables ["Order"].Columns ["custid"]); drcol.Add(dr1); Assert.That(drcol.ToString(), Is.EqualTo("System.Data.DataRelationCollection"), "test#1"); Console.WriteLine(drcol.ToString()); }
public void Equals() { DataRelationCollection drcol = _dataset.Relations; drcol.Add("CustOrder" , _dataset.Tables["Customer"].Columns["custid"] , _dataset.Tables["Order"].Columns["custid"]); drcol.Add("ItemOrder" , _dataset.Tables["Item"].Columns["itemid"] , _dataset.Tables["Order"].Columns["custid"]); DataSet newds = new DataSet(); DataRelationCollection drcol1 = newds.Relations; DataRelationCollection drcol2 = _dataset.Relations; AssertEquals("test#1", true, drcol.Equals(drcol)); AssertEquals("test#2", true, drcol.Equals(drcol2)); AssertEquals("test#3", false, drcol1.Equals(drcol)); AssertEquals("test#4", false, drcol.Equals(drcol1)); AssertEquals("test#5", true, Object.Equals(drcol, drcol2)); AssertEquals("test#6", false, Object.Equals(drcol, drcol1)); }
public void Equals() { DataRelationCollection drcol = _dataset.Relations; drcol.Add("CustOrder" , _dataset.Tables ["Customer"].Columns ["custid"] , _dataset.Tables ["Order"].Columns ["custid"]); drcol.Add("ItemOrder" , _dataset.Tables ["Item"].Columns ["itemid"] , _dataset.Tables ["Order"].Columns ["custid"]); DataSet newds = new DataSet(); DataRelationCollection drcol1 = newds.Relations; DataRelationCollection drcol2 = _dataset.Relations; Assert.That(drcol.Equals(drcol), Is.True, "test#1"); Assert.That(drcol.Equals(drcol2), Is.True, "test#2"); Assert.That(drcol1.Equals(drcol), Is.False, "test#3"); Assert.That(drcol.Equals(drcol1), Is.False, "test#4"); Assert.That(Object.Equals(drcol, drcol2), Is.True, "test#5"); Assert.That(Object.Equals(drcol, drcol1), Is.False, "test#6"); }
public void CopyTo() { DataRelationCollection drcol = _dataset.Relations; drcol.Add("CustOrder" , _dataset.Tables["Customer"].Columns["custid"] , _dataset.Tables["Order"].Columns["custid"]); drcol.Add("ItemOrder" , _dataset.Tables["Item"].Columns["itemid"] , _dataset.Tables["Order"].Columns["custid"]); DataRelation[] array = new DataRelation[2]; drcol.CopyTo(array, 0); Assert.Equal(2, array.Length); Assert.Equal("CustOrder", array[0].RelationName); Assert.Equal("ItemOrder", array[1].RelationName); DataRelation[] array1 = new DataRelation[4]; drcol.CopyTo(array1, 2); Assert.Null(array1[0]); Assert.Null(array1[1]); Assert.Equal("CustOrder", array1[2].RelationName); Assert.Equal("ItemOrder", array1[3].RelationName); }
public void Contains() { 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.True(drcol.Contains(dr.RelationName)); string drnull = ""; Assert.False(drcol.Contains(drnull)); dr = new DataRelation("newRelation", childCol, parentCol); Assert.False(drcol.Contains("NoSuchRelation")); }
public void CopyTo() { DataRelationCollection drcol = _dataset.Relations; drcol.Add("CustOrder" , _dataset.Tables["Customer"].Columns["custid"] , _dataset.Tables["Order"].Columns["custid"]); drcol.Add("ItemOrder" , _dataset.Tables["Item"].Columns["itemid"] , _dataset.Tables["Order"].Columns["custid"]); DataRelation [] array = new DataRelation[2]; drcol.CopyTo(array, 0); AssertEquals("test#1", 2, array.Length); AssertEquals("test#2", "CustOrder", array[0].RelationName); AssertEquals("test#3", "ItemOrder", array[1].RelationName); DataRelation [] array1 = new DataRelation[4]; drcol.CopyTo(array1, 2); AssertEquals("test#4", null, array1[0]); AssertEquals("test#5", null, array1[1]); AssertEquals("test#6", "CustOrder", array1[2].RelationName); AssertEquals("test#7", "ItemOrder", array1[3].RelationName); }
public void CopyTo() { DataRelationCollection drcol = _dataset.Relations; drcol.Add("CustOrder" , _dataset.Tables ["Customer"].Columns ["custid"] , _dataset.Tables ["Order"].Columns ["custid"]); drcol.Add("ItemOrder" , _dataset.Tables ["Item"].Columns ["itemid"] , _dataset.Tables ["Order"].Columns ["custid"]); DataRelation [] array = new DataRelation[2]; drcol.CopyTo(array, 0); Assert.That(array.Length, Is.EqualTo(2), "test#1"); Assert.That(array [0].RelationName, Is.EqualTo("CustOrder"), "test#2"); Assert.That(array [1].RelationName, Is.EqualTo("ItemOrder"), "test#3"); DataRelation [] array1 = new DataRelation[4]; drcol.CopyTo(array1, 2); Assert.That(array1 [0], Is.Null, "test#4"); Assert.That(array1 [1], Is.Null, "test#5"); Assert.That(array1 [2].RelationName, Is.EqualTo("CustOrder"), "test#6"); Assert.That(array1 [3].RelationName, Is.EqualTo("ItemOrder"), "test#7"); }
public void CanRemove() { 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.True(drcol.CanRemove(dr)); Assert.False(drcol.CanRemove(null)); DataRelation dr2 = new DataRelation("ItemOrder" , _dataset.Tables["Item"].Columns["itemid"] , _dataset.Tables["Order"].Columns["custid"]); Assert.False(drcol.CanRemove(dr2)); }
private void AddRelation(DataColumn parentChapterColumn, DataColumn chapterColumn) { if (this._dataSet != null) { string columnName = chapterColumn.ColumnName; DataRelation relation = new DataRelation(columnName, new DataColumn[] { parentChapterColumn }, new DataColumn[] { chapterColumn }, false); int num = 1; string relationName = columnName; DataRelationCollection relations = this._dataSet.Relations; while (-1 != relations.IndexOf(relationName)) { relationName = columnName + num; num++; } relation.RelationName = relationName; relations.Add(relation); } }
private void AddRelation(DataColumn parentChapterColumn, DataColumn chapterColumn) // MDAC 71613 { if (null != this.dataSet) { string name = /*parentChapterColumn.ColumnName + "_" +*/ chapterColumn.ColumnName; // MDAC 72815 DataRelation relation = new DataRelation(name, new DataColumn[] { parentChapterColumn }, new DataColumn[] { chapterColumn }, false); // MDAC 71878 int index = 1; string tmp = name; DataRelationCollection relations = this.dataSet.Relations; while (-1 != relations.IndexOf(tmp)) { tmp = name + index; index++; } relation.RelationName = tmp; relations.Add(relation); } }