public void ITableMappingCollectionIndexer() { ITableMappingCollection collection = new DataTableMappingCollection(); Assert.Throws <IndexOutOfRangeException>(() => { var x = collection["source"]; }); Assert.Throws <IndexOutOfRangeException>(() => { collection["source"] = new DataTableMapping(); }); ITableMapping mapping = collection.Add("source", "dataSet"); Assert.Same(mapping, collection["source"]); Assert.Same(mapping, collection.GetByDataSetTable("dataSet")); Assert.Throws <ArgumentNullException>(() => { collection["source"] = null; }); Assert.Throws <InvalidCastException>(() => { collection["source"] = "invalid"; }); ITableMapping mapping2 = new DataTableMapping("source2", "dataSet2"); collection["source"] = mapping2; Assert.Single(collection); Assert.Same(mapping2, collection["source2"]); Assert.Throws <IndexOutOfRangeException>(() => collection.GetByDataSetTable("dataSet")); }
// <Snippet1> public void FindDataTableMapping() { // ... // create mappings and mapping // ... if (mappings.IndexOfDataSetTable("datacategories") != -1) { mapping = mappings.GetByDataSetTable("datacategories"); } }
public void GetByDataSetTable() { _tableMapCollection.AddRange(_tabs); bool eq; DataTableMapping tab1; tab1 = _tableMapCollection.GetByDataSetTable("dataSetCustomers"); eq = (tab1.DataSetTable.Equals("dataSetCustomers") && tab1.SourceTable.Equals("sourceCustomers")); Assert.True(eq); tab1 = _tableMapCollection.GetByDataSetTable("dataSetEmployees"); eq = (tab1.DataSetTable.Equals("dataSetEmployees") && tab1.SourceTable.Equals("sourceEmployees")); Assert.True(eq); tab1 = _tableMapCollection.GetByDataSetTable("datasetcustomers"); eq = (tab1.DataSetTable.Equals("dataSetCustomers") && tab1.SourceTable.Equals("sourceCustomers")); Assert.True(eq); tab1 = _tableMapCollection.GetByDataSetTable("datasetemployees"); eq = (tab1.DataSetTable.Equals("dataSetEmployees") && tab1.SourceTable.Equals("sourceEmployees")); Assert.True(eq); }
public void GetByDataSetTable() { tableMapCollection.AddRange(tabs); bool eq; DataTableMapping tab1; tab1 = tableMapCollection.GetByDataSetTable("dataSetCustomers"); eq = (tab1.DataSetTable.Equals("dataSetCustomers") && tab1.SourceTable.Equals("sourceCustomers")); Assert.AreEqual(true, eq, "test1"); tab1 = tableMapCollection.GetByDataSetTable("dataSetEmployees"); eq = (tab1.DataSetTable.Equals("dataSetEmployees") && tab1.SourceTable.Equals("sourceEmployees")); Assert.AreEqual(true, eq, "test2"); tab1 = tableMapCollection.GetByDataSetTable("datasetcustomers"); eq = (tab1.DataSetTable.Equals("dataSetCustomers") && tab1.SourceTable.Equals("sourceCustomers")); Assert.AreEqual(true, eq, "test3"); tab1 = tableMapCollection.GetByDataSetTable("datasetemployees"); eq = (tab1.DataSetTable.Equals("dataSetEmployees") && tab1.SourceTable.Equals("sourceEmployees")); Assert.AreEqual(true, eq, "test4"); }