public void DataListConversionUtilTest_CreateListToBindTo_WhenColumnHasInputMapping_ExpectCollectionWithOneItem() { //------------Setup for test-------------------------- var converter = new DataListConversionUtils(); const string Data = "<DataList></DataList>"; const string Shape = @"<DataList><rec Description="""" IsEditable=""True"" ColumnIODirection=""None"" ><a Description="""" IsEditable=""True"" ColumnIODirection=""Input"" /><b Description="""" IsEditable=""True"" ColumnIODirection=""None"" /></rec></DataList>"; //------------Execute Test--------------------------- var bdl = new DataListModel(); bdl.Create(Data, Shape); var result = converter.CreateListToBindTo(bdl); //------------Assert Results------------------------- Assert.AreEqual(1, result.Count); Assert.AreEqual("rec", result[0].Recordset); Assert.AreEqual("a", result[0].Field); }
// ReSharper disable InconsistentNaming public void DataListConversionUtilTest_CreateListToBindTo_WhenScalarHasInputMapping_ExpectCollectionWithOneItem() // ReSharper restore InconsistentNaming { //------------Setup for test-------------------------- var converter = new DataListConversionUtils(); const string Data = "<DataList></DataList>"; const string Shape = @"<DataList><scalar Description="""" IsEditable=""True"" ColumnIODirection=""Input"" ></scalar></DataList>"; //------------Execute Test--------------------------- var bdl = new DataListModel(); bdl.Create(Data, Shape); var result = converter.CreateListToBindTo(bdl); //------------Assert Results------------------------- Assert.AreEqual(1, result.Count); Assert.AreEqual("scalar", result[0].Field); }
/// <summary> /// Generates the match fragments from data list. /// </summary> /// <returns></returns> private FuzzyMatchVo GenerateMatchFragmentsFromDataList() { FuzzyMatchVo result = null; if (!string.IsNullOrEmpty(DataList)) { var dataListModel = new DataListModel(); dataListModel.Create(DataList,DataList); IDictionary<Tuple<string, string>, string> tmp = new Dictionary<Tuple<string, string>, string>(); foreach (var rs in dataListModel.RecordSets) { // build map for each column in a recordset ;) foreach (var col in rs.Columns) { foreach(var scalar in col.Value) { if (!tmp.Keys.Any(a => a.Item2 == scalar.Name && a.Item1 == rs.Name)) { tmp[new Tuple<string, string>(rs.Name, scalar.Name)] = rs.Name; } } } } result = new FuzzyMatchVo(tmp); } return result; }
public void DataListConversionUtilTest_CreateListToBindTo_WhenScalarHasNoneMapping_ExpectCollectionWithNoItems() { //------------Setup for test-------------------------- var converter = new DataListConversionUtils(); const string Data = "<DataList></DataList>"; const string Shape = @"<DataList><scalar Description="""" IsEditable=""True"" ColumnIODirection=""None"" ></scalar></DataList>"; //------------Execute Test--------------------------- var bdl = new DataListModel(); bdl.Create(Data, Shape); var result = converter.CreateListToBindTo(bdl); //------------Assert Results------------------------- Assert.AreEqual(0, result.Count); }