public void FetchFromList_Expected_NonNullDisplayName() { string error; IBinaryDataList dl1; dl1 = Dev2BinaryDataListFactory.CreateDataList(); IList <Dev2Column> cols = new List <Dev2Column>(); cols.Add(Dev2BinaryDataListFactory.CreateColumn("field1")); dl1.TryCreateRecordsetTemplate("recset", "", cols, true, out error); dl1.TryCreateRecordsetValue("value", "field1", "recset", 1, out error); IBinaryDataListEntry entry; dl1.TryGetEntry("recset", out entry, out error); // DataList Cleanup ;) Assert.AreEqual("recset(1).field1", entry.FetchRecordAt(1, out error).First().DisplayValue); Assert.AreEqual(error, ""); }
public void UpperFirst_StringContainingNumerics_Expected_All_FirstLetterUpperCase() { IBinaryDataListItem item = Dev2BinaryDataListFactory.CreateBinaryItem("5make1 1first 3letter up5percase", ""); IBinaryDataListItem result = converter.TryConvert("Sentence", item); Assert.AreEqual("5make1 1first 3letter up5percase", result.TheValue); }
/// <summary> /// Converts a list of data list item view models to a binary data list. /// </summary> /// <param name="errorString">The error string.</param> /// <returns></returns> private IBinaryDataList ConvertIDataListItemModelsToIBinaryDataList(out string errorString) { errorString = string.Empty; IBinaryDataList result = Dev2BinaryDataListFactory.CreateDataList(); IList <IDataListItemModel> filledScalars = ScalarCollection != null?ScalarCollection.Where(scalar => !scalar.IsBlank && !scalar.HasError).ToList() : new List <IDataListItemModel>(); foreach (var scalar in filledScalars) { result.TryCreateScalarTemplate (string.Empty, scalar.Name, scalar.Description , true, scalar.IsEditable, scalar.ColumnIODirection, out errorString); } foreach (var recset in RecsetCollection ?? new OptomizedObservableCollection <IDataListItemModel>()) { if (recset.IsBlank) { continue; } IEnumerable <IDataListItemModel> filledRecordSets = recset.Children.Where(c => !c.IsBlank && !c.HasError); IList <Dev2Column> cols = filledRecordSets.Select(child => DataListFactory.CreateDev2Column(child.Name, child.Description, child.IsEditable, child.ColumnIODirection)) .ToList(); result.TryCreateRecordsetTemplate(recset.Name, recset.Description, cols, true, recset.IsEditable, recset.ColumnIODirection, out errorString); } return(result); }
public void TitleCase_StringWithNumeric_Expected_All_FirstLetterUpperCaseOnAll() { IBinaryDataListItem item = Dev2BinaryDataListFactory.CreateBinaryItem("1make fi5rst le6tter up3percase", ""); IBinaryDataListItem result = converter.TryConvert("Title Case", item); Assert.AreEqual("1make Fi5rst Le6tter Up3percase", result.TheValue); }
public void AllUpper_Complex_String_Expected_All_UpperCase() { IBinaryDataListItem item = Dev2BinaryDataListFactory.CreateBinaryItem("string.(to)@ 'make' u//ppercase", ""); IBinaryDataListItem result = converter.TryConvert("UPPER", item); Assert.AreEqual("STRING.(TO)@ 'MAKE' U//PPERCASE", result.TheValue); }
public void DeSerializeToXMLInputsOnlyFromBinary_ValidXML_Expect_Sucess() { IBinaryDataList dl = Dev2BinaryDataListFactory.CreateDataList(); List <Dev2Column> cols1 = new List <Dev2Column> { DataListFactory.CreateDev2Column("f1", ""), }; List <Dev2Column> cols2 = new List <Dev2Column> { DataListFactory.CreateDev2Column("f2", ""), }; string error; ErrorResultTO errors; IDataListTranslator xmlConverter = Dls.GetTranslator(XmlFormatInputsOnly); dl.TryCreateRecordsetTemplate("rs1", "", cols1, true, out error); dl.TryCreateRecordsetTemplate("rs2", "", cols2, true, true, enDev2ColumnArgumentDirection.Input, out error); dl.TryCreateScalarTemplate("", "scalar1", "", true, true, enDev2ColumnArgumentDirection.Input, out error); dl.TryCreateScalarTemplate("", "scalar2", "", true, true, enDev2ColumnArgumentDirection.Output, out error); dl.TryCreateScalarValue("scalar1Value", "scalar1", out error); dl.TryCreateScalarValue("scalar2Value", "scalar2", out error); dl.TryCreateRecordsetValue("rec1.f1.value", "f1", "rs1", 1, out error); dl.TryCreateRecordsetValue("rec1.f2.value", "f2", "rs2", 1, out error); dl.TryCreateRecordsetValue("rec2.f1.value", "f1", "rs1", 2, out error); dl.TryCreateRecordsetValue("rec2.f2.value", "f2", "rs2", 2, out error); DataListTranslatedPayloadTO tmp = xmlConverter.ConvertFrom(dl, out errors); string result = tmp.FetchAsString().ToString(); Assert.AreEqual("<DataList><scalar1>scalar1Value</scalar1></DataList>", result); }
public void DeSerializeToXMLFromBinary_InvertedIndexInsert_ValidXML_Expect_Sucess() { IBinaryDataList dl = Dev2BinaryDataListFactory.CreateDataList(); string error; List <Dev2Column> cols = new List <Dev2Column>(); ErrorResultTO errors; cols.Add(DataListFactory.CreateDev2Column("f1", "")); cols.Add(DataListFactory.CreateDev2Column("f2", "")); cols.Add(DataListFactory.CreateDev2Column("f3", "")); IDataListTranslator xmlConverter = Dls.GetTranslator(XmlFormat); dl.TryCreateRecordsetTemplate("rs1", "", cols, true, out error); dl.TryCreateScalarTemplate(string.Empty, "scalar1", "", true, out error); dl.TryCreateScalarValue("scalar1Value", "scalar1", out error); dl.TryCreateRecordsetValue("rec1.f2.vale", "f2", "rs1", 1, out error); dl.TryCreateRecordsetValue("rec1.f1.vale", "f1", "rs1", 1, out error); dl.TryCreateRecordsetValue("rec1.f3.vale", "f3", "rs1", 1, out error); dl.TryCreateRecordsetValue("rec2.f1.vale", "f1", "rs1", 2, out error); dl.TryCreateRecordsetValue("rec2.f2.vale", "f2", "rs1", 2, out error); dl.TryCreateRecordsetValue("rec2.f3.vale", "f3", "rs1", 2, out error); DataListTranslatedPayloadTO tmp = xmlConverter.ConvertFrom(dl, out errors); string result = tmp.FetchAsString().ToString(); Assert.AreEqual("<DataList><rs1><f1>rec1.f1.vale</f1><f2>rec1.f2.vale</f2><f3>rec1.f3.vale</f3></rs1><rs1><f1>rec2.f1.vale</f1><f2>rec2.f2.vale</f2><f3>rec2.f3.vale</f3></rs1><scalar1>scalar1Value</scalar1></DataList>", result); }
public void AllLower_Simple_String_Expected_All_LowerCase() { IBinaryDataListItem item = Dev2BinaryDataListFactory.CreateBinaryItem("STRING TO MAKE LOWERCASE", ""); IBinaryDataListItem result = converter.TryConvert("lower", item); Assert.AreEqual("string to make lowercase", result.TheValue); }
public void AllLower_StringContainingNumerics_Expected_All_LowerCase() { IBinaryDataListItem item = Dev2BinaryDataListFactory.CreateBinaryItem("2STRING T4O M6AKE LO08WERCASE", ""); IBinaryDataListItem result = converter.TryConvert("lower", item); Assert.AreEqual("2string t4o m6ake lo08wercase", result.TheValue); }
public void AllUpper_StringContainingNumerics_Expected_All_UpperCase() { IBinaryDataListItem item = Dev2BinaryDataListFactory.CreateBinaryItem("2strinG 4To 8m9ake upp522erc7ase", ""); IBinaryDataListItem result = converter.TryConvert("UPPER", item); Assert.AreEqual("2STRING 4TO 8M9AKE UPP522ERC7ASE", result.TheValue); }
public IBinaryDataList DeSerialize(string data, string targetShape, enTranslationTypes typeOf, out string error) { error = string.Empty; IBinaryDataList result = Dev2BinaryDataListFactory.CreateDataList(); IDataListCompiler compiler = DataListFactory.CreateDataListCompiler(); if (typeOf == enTranslationTypes.XML) { ErrorResultTO errors; Guid resultId = compiler.ConvertTo(DataListFormat.CreateFormat(GlobalConstants._Studio_Debug_XML), data.ToStringBuilder(), new StringBuilder(targetShape), out errors); if (errors.HasErrors()) { error = errors.FetchErrors()[0]; // take the first error ;) } else { if (result != null) { compiler.ForceDeleteDataListByID(result.UID); } result = compiler.FetchBinaryDataList(resultId, out errors); if (errors.HasErrors()) { error = errors.FetchErrors()[0]; // take the first error ;) } } } return(result); }
public void TitleCase_Complex_String_Expected_All_FirstLetterUpperCaseOnAll() { IBinaryDataListItem item = Dev2BinaryDataListFactory.CreateBinaryItem("make.(first)@ 'letter'//cap", ""); IBinaryDataListItem result = converter.TryConvert("Title Case", item); Assert.AreEqual("Make.(First)@ 'Letter'//Cap", result.TheValue); }
public void XmlTranslator_ConvertAndFilter_WhenRecordsetWithGaps_ExpectRowAnnotations() { //------------Setup for test-------------------------- IDataListTranslator xmlConverter = Dls.GetTranslator(XmlFormatWithoutSystemTags); IBinaryDataList dl1 = Dev2BinaryDataListFactory.CreateDataList(GlobalConstants.NullDataListID); string error; var cols = new List <Dev2Column> { DataListFactory.CreateDev2Column("val", string.Empty) }; dl1.TryCreateRecordsetTemplate("rs", string.Empty, cols, true, out error); dl1.TryCreateRecordsetValue("1", "val", "rs", 1, out error); dl1.TryCreateRecordsetValue("3", "val", "rs", 3, out error); //------------Execute Test--------------------------- ErrorResultTO errors; var actual = xmlConverter.ConvertAndFilter(dl1, "<root><rs><val/></rs></root>".ToStringBuilder(), out errors); actual = actual.Replace("\r", "").Replace("\n", ""); //------------Assert Results------------------------- const string expected = "<rs index=\"1\"><val>1</val></rs><rs index=\"3\"><val>3</val></rs>"; StringAssert.Contains(actual.ToString(), expected, "rowID attribute not present"); }
public void TitleCase_Simple_String_All_Caps_Expected_All_FirstLetterUpperCaseOnAll() { IBinaryDataListItem item = Dev2BinaryDataListFactory.CreateBinaryItem("MAKE FIRST LETTER UPPERCASE", ""); IBinaryDataListItem result = converter.TryConvert("Title Case", item); Assert.AreEqual("MAKE FIRST LETTER UPPERCASE", result.TheValue); }
public void UpperFirst_Simple_String_Expected_All_FirstLetterUpperCase() { IBinaryDataListItem item = Dev2BinaryDataListFactory.CreateBinaryItem("make first letter uppercase", ""); IBinaryDataListItem result = converter.TryConvert("Sentence", item); Assert.AreEqual("Make first letter uppercase", result.TheValue); }
/// <summary> /// Converts a list of data list item view models to a binary data list. /// </summary> /// <param name="listToConvert">The list to convert.</param> /// <param name="errorString">The error string.</param> /// <returns></returns> private IBinaryDataList ConvertIDataListItemModelsToIBinaryDataList(out string errorString) { errorString = string.Empty; IBinaryDataList result = Dev2BinaryDataListFactory.CreateDataList(); foreach (IDataListItemModel scalar in ScalarCollection) { if (!scalar.IsBlank && !scalar.HasError) { result.TryCreateScalarTemplate(string.Empty, scalar.Name, scalar.Description, true, scalar.IsEditable, scalar.ColumnIODirection, out errorString); } } foreach (IDataListItemModel recset in RecsetCollection) { if (!recset.IsBlank && !recset.HasError) { IList <Dev2Column> cols = new List <Dev2Column>(); foreach (IDataListItemModel child in recset.Children.Where(c => !c.IsBlank && !c.HasError)) { cols.Add(DataListFactory.CreateDev2Column(child.Name, child.Description, child.IsEditable, child.ColumnIODirection)); } result.TryCreateRecordsetTemplate(recset.Name, recset.Description, cols, true, recset.IsEditable, recset.ColumnIODirection, out errorString); } } return(result); }
public IBinaryDataListItem TryConvert(string conversionType, IBinaryDataListItem item) { Func <string, string> returnedFunc; IBinaryDataListItem result = Dev2BinaryDataListFactory.CreateBinaryItem("Error Invalid Conversion Type", GlobalConstants.EvalautionScalar); if (_convertFunctions.TryGetValue(conversionType, out returnedFunc)) { if (returnedFunc != null) { string tmp = returnedFunc.Invoke(item.TheValue); if (item.Namespace != string.Empty) { result = Dev2BinaryDataListFactory.CreateBinaryItem(tmp, item.Namespace, item.FieldName, item.ItemCollectionIndex); } else { result = Dev2BinaryDataListFactory.CreateBinaryItem(tmp, item.FieldName); } } } return(result); }
public void TryFetchLastIndexedRecordsetUpsertPayload_ColumnName_FetchesForColumn() { //------------Setup for test-------------------------- IDataListCompiler compiler = DataListFactory.CreateDataListCompiler(); IDev2DataListUpsertPayloadBuilder <List <string> > toUpsert = Dev2DataListBuilderFactory.CreateStringListDataListUpsertBuilder(); toUpsert.Add("[[rec().f1]]", new List <string> { "test11", "test12" }); toUpsert.Add("[[rec().f2]]", new List <string> { "test21", "test22" }); IBinaryDataList dataList = Dev2BinaryDataListFactory.CreateDataList(); string creationError; dataList.TryCreateRecordsetTemplate("rec", "recset", new List <Dev2Column> { DataListFactory.CreateDev2Column("f1", "f1"), DataListFactory.CreateDev2Column("f2", "f2") }, true, out creationError); ErrorResultTO localErrors; compiler.PushBinaryDataList(dataList.UID, dataList, out localErrors); compiler.Upsert(dataList.UID, toUpsert, out _errors); IBinaryDataListEntry recEntry; string error; dataList.TryGetEntry("rec", out recEntry, out error); //------------Assert Preconditions------------------- Assert.IsNotNull(recEntry); //------------Execute Test--------------------------- var listItem = recEntry.TryFetchLastIndexedRecordsetUpsertPayload(out error, "f2"); //------------Assert Results------------------------- Assert.AreEqual("test22", listItem.TheValue); }
public void MyTestInitialize() { string error; var dataListCompiler = DataListFactory.CreateDataListCompiler(); _dl1 = Dev2BinaryDataListFactory.CreateDataList(); _dl1.TryCreateScalarTemplate(string.Empty, "myScalar", "A scalar", true, out error); _dl1.TryCreateScalarValue("[[otherScalar]]", "myScalar", out error); _dl1.TryCreateScalarTemplate(string.Empty, "otherScalar", "A scalar", true, out error); _dl1.TryCreateScalarValue("testRegion", "otherScalar", out error); _dl1.TryCreateScalarTemplate(string.Empty, "scalar1", "A scalar", true, out error); _dl1.TryCreateScalarValue("foobar", "scalar1", out error); IList <Dev2Column> cols = new List <Dev2Column>(); cols.Add(Dev2BinaryDataListFactory.CreateColumn("f1")); cols.Add(Dev2BinaryDataListFactory.CreateColumn("f2")); cols.Add(Dev2BinaryDataListFactory.CreateColumn("f3")); _dl1.TryCreateRecordsetTemplate("recset", "a recordset", cols, true, out error); _dl1.TryCreateRecordsetValue("r1.f1.value", "f1", "recset", 1, out error); _dl1.TryCreateRecordsetValue("r1.f2.value", "f2", "recset", 1, out error); _dl1.TryCreateRecordsetValue("r1.f3.value", "f3", "recset", 1, out error); _dl1.TryCreateRecordsetValue("r2.f1.value", "f1", "recset", 2, out error); _dl1.TryCreateRecordsetValue("r2.f2.value", "f2", "recset", 2, out error); _dl1.TryCreateRecordsetValue("r2.f3.value", "f3", "recset", 2, out error); // skip 3 ;) _dl1.TryCreateRecordsetValue("r4.f1.value", "f1", "recset", 4, out error); _dl1.TryCreateRecordsetValue("r4.f2.value", "f2", "recset", 4, out error); _dl1.TryCreateRecordsetValue("r4.f3.value", "f3", "recset", 4, out error); dataListCompiler.PushBinaryDataList(_dl1.UID, _dl1, out _errors); //_compiler.UpsertSystemTag(dl1.UID, enSystemTag.EvaluateIteration, "true", out errors); /* list 2 */ _dl2 = Dev2BinaryDataListFactory.CreateDataList(); _dl2.TryCreateScalarTemplate(string.Empty, "idx", "A scalar", true, out error); _dl2.TryCreateScalarValue("1", "idx", out error); _dl2.TryCreateRecordsetTemplate("recset", "a recordset", cols, true, out error); _dl2.TryCreateRecordsetValue("r1.f1.value", "f1", "recset", 1, out error); _dl2.TryCreateRecordsetValue("r1.f2.value", "f2", "recset", 1, out error); _dl2.TryCreateRecordsetValue("r1.f3.value", "f3", "recset", 1, out error); _dl2.TryCreateRecordsetValue("r2.f1.value", "f1", "recset", 2, out error); _dl2.TryCreateRecordsetValue("r2.f2.value", "f2", "recset", 2, out error); _dl2.TryCreateRecordsetValue("r2.f3.value", "f3", "recset", 2, out error); dataListCompiler.PushBinaryDataList(_dl2.UID, _dl2, out _errors); //_compiler.UpsertSystemTag(dl2.UID, enSystemTag.EvaluateIteration, "true", out errors); }
static ISimulationResult CreateResult(ISimulationKey key) { return(new SimulationResult { Key = key, Value = Dev2BinaryDataListFactory.CreateDataList() }); }
static string ExtractKeyValuePairs(NameValueCollection pairs) { IBinaryDataList bdl = Dev2BinaryDataListFactory.CreateDataList(); // Extract request keys ;) foreach (var key in pairs.AllKeys) { if (key == "wid") //Don't add the Workspace ID to DataList { continue; } if (key.IsXml()) { return(key); //We have a workspace id and XML DataList } string error; bdl.TryCreateScalarTemplate(string.Empty, key, string.Empty, true, out error); if (!string.IsNullOrEmpty(error)) { Dev2Logger.Log.Error(error); } IBinaryDataListEntry entry; if (bdl.TryGetEntry(key, out entry, out error)) { var item = Dev2BinaryDataListFactory.CreateBinaryItem(pairs[key], key); entry.TryPutScalar(item, out error); if (!string.IsNullOrEmpty(error)) { Dev2Logger.Log.Error(error); } } else { Dev2Logger.Log.Error(error); } } IDataListCompiler compiler = DataListFactory.CreateDataListCompiler(); ErrorResultTO errors; Guid pushedId = compiler.PushBinaryDataList(bdl.UID, bdl, out errors); if (pushedId != Guid.Empty) { var result = compiler.ConvertFrom(pushedId, DataListFormat.CreateFormat(GlobalConstants._XML), enTranslationDepth.Data, out errors); if (errors.HasErrors()) { Dev2Logger.Log.Error(errors.MakeDisplayReady()); } return(result.ToString()); } Dev2Logger.Log.Error(errors.MakeDisplayReady()); return(string.Empty); }
public void RecordsetGroup_Constructor_WhenDefinitionsNull_ExpectException() { //------------Setup for test-------------------------- var entry = Dev2BinaryDataListFactory.CreateEntry(string.Empty, string.Empty, Guid.NewGuid()); //------------Execute Test--------------------------- var recordsetGroup = new RecordsetGroup(entry, null, definition => null, definition => null); }
public static void MyClassInitialize(TestContext testContext) { Directory.SetCurrentDirectory(testContext.TestDir); _testInstance = SimulationRepository.Instance; _testResult = new SimulationResult { Key = CreateKey(), Value = Dev2BinaryDataListFactory.CreateDataList() }; _testInstance.Save(_testResult); }
public void Clone_50EntryRS_1kTimes_AtDepth() { string error; IBinaryDataList dl1 = Dev2BinaryDataListFactory.CreateDataList(GlobalConstants.NullDataListID); IList <Dev2Column> cols = new List <Dev2Column>(); cols.Add(Dev2BinaryDataListFactory.CreateColumn("f1")); cols.Add(Dev2BinaryDataListFactory.CreateColumn("f2")); cols.Add(Dev2BinaryDataListFactory.CreateColumn("f3")); cols.Add(Dev2BinaryDataListFactory.CreateColumn("f4")); cols.Add(Dev2BinaryDataListFactory.CreateColumn("f5")); const int r = 50; const int runs = 1000; dl1.TryCreateRecordsetTemplate("recset", string.Empty, cols, true, out error); for (int i = 0; i < r; i++) { dl1.TryCreateRecordsetValue("r1.f1.value r1.f1.value r1.f1.valuer1.f1.valuer1.f1.value", "f1", "recset", (i + 1), out error); dl1.TryCreateRecordsetValue("r1.f2.value", "f2", "recset", (i + 1), out error); dl1.TryCreateRecordsetValue("r1.f3.valuer1.f3.valuer1.f3.valuer1.f3.valuer1.f3.valuer1.f3.valuer1.f3.value", "f3", "recset", (i + 1), out error); dl1.TryCreateRecordsetValue("r1.f3.value", "f4", "recset", (i + 1), out error); dl1.TryCreateRecordsetValue("r1.f3.value r1.f3.value v r1.f3.value r1.f3.value", "f5", "recset", (i + 1), out error); } DateTime start1 = DateTime.Now; string er; IBinaryDataListEntry val; bool tryGetEntry = dl1.TryGetEntry("recset", out val, out er); for (int q = 0; q < runs; q++) { if (tryGetEntry) { val.Clone(enTranslationDepth.Data, dl1.UID, out er); } } DateTime end1 = DateTime.Now; long ticks = (end1.Ticks - start1.Ticks); double result1 = (ticks / _ticksPerSec); Console.WriteLine(result1 + @" seconds for " + runs + @" to clone "); Assert.IsTrue(result1 <= 10.5); // Given .01 buffer ;) WAS : 0.065 }
public void CanIterateNormally() { const int maxValue = 5; IIndexIterator ii = Dev2BinaryDataListFactory.CreateLoopedIndexIterator(10, maxValue); int cnt = 0; while (ii.HasMore()) { ii.FetchNextIndex(); cnt++; } Assert.AreEqual(maxValue, cnt); }
/// <summary> /// Gets the wizard data list for a workflow. /// </summary> /// <param name="dataList"></param> /// <returns> /// The string for the data list /// </returns> /// <exception cref="System.Exception"> /// </exception> public string GetWizardDataListForWorkflow(string dataList) { IBinaryDataList newDl = Dev2BinaryDataListFactory.CreateDataList(); ErrorResultTO errors; var dataListStringBuilder = new StringBuilder(dataList); Guid dlID = ConvertTo(DataListFormat.CreateFormat(GlobalConstants._XML_Without_SystemTags), dataListStringBuilder, dataListStringBuilder, out errors); if (!errors.HasErrors()) { IBinaryDataList dl = FetchBinaryDataList(dlID, out errors); if (!errors.HasErrors()) { IList <IBinaryDataListEntry> entries = dl.FetchAllEntries(); foreach (IBinaryDataListEntry entry in entries) { if (entry.IsRecordset) { if (entry.ColumnIODirection != enDev2ColumnArgumentDirection.None) { string tmpError; newDl.TryCreateRecordsetTemplate(entry.Namespace, entry.Description, entry.Columns, true, out tmpError); } } else { if (entry.ColumnIODirection != enDev2ColumnArgumentDirection.None) { string tmpError; IBinaryDataListItem scalar = entry.FetchScalar(); newDl.TryCreateScalarTemplate(string.Empty, scalar.FieldName, entry.Description, true, out tmpError); } } } Guid newDlId = PushBinaryDataList(newDl.UID, newDl, out errors); dataList = ConvertFrom(newDlId, DataListFormat.CreateFormat(GlobalConstants._XML_Without_SystemTags), enTranslationDepth.Shape, out errors).ToString(); } else { throw new Exception(errors.MakeUserReady()); } } else { throw new Exception(errors.MakeUserReady()); } return(dataList); }
public void DeserializeToXMLFromBinaryDataListWhereDataListContainsInvalidXMLCharactersExpectedInvalidCharactersAreEscaped() { IDataListTranslator xmlConverter = Dls.GetTranslator(XmlFormat); IBinaryDataList dl1 = Dev2BinaryDataListFactory.CreateDataList(GlobalConstants.NullDataListID); string error; dl1.TryCreateScalarTemplate(string.Empty, "cake", "", false, true, enDev2ColumnArgumentDirection.Both, out error); dl1.TryCreateScalarValue("Travis Is \"Cool\"&>'nstuff'<", "cake", out error); ErrorResultTO errors; var payload = xmlConverter.ConvertFrom(dl1, out errors); string actual = payload.FetchAsString().ToString(); const string expected = "Travis Is \"Cool\"&>'nstuff'<"; StringAssert.Contains(actual, expected, "Not all XML special characters are escaped i.e \"'><&"); }
public void BaseConvertRecsetWithStarIndexToBinaryExpectedOutputToCorrectRecords() { SetupArguments( @"<root></root>" , ActivityStrings.BaseConvert_DLShape.Replace("<ADL>", "<ADL><setup/>") , new List <BaseConvertTO> { new BaseConvertTO("", "Text", "Binary", "[[setup]]", 1) } ); IDSFDataObject result = ExecuteProcess(); ErrorResultTO errorResult; IBinaryDataList bdl = Compiler.FetchBinaryDataList(result.DataListID, out errorResult); IBinaryDataListItem isolatedRecord = Dev2BinaryDataListFactory.CreateBinaryItem("CONVERT THIS TO BINARY", "Field"); string error; IBinaryDataListEntry entry; bdl.TryGetEntry("Recset", out entry, out error); entry.TryPutRecordItemAtIndex(isolatedRecord, 5, out error); IList <BaseConvertTO> convertCollection = new List <BaseConvertTO> { new BaseConvertTO("[[Recset(*).Field]]", "Text", "Binary", "[[Recset(*).Field]]", 1) }; TestStartNode = new FlowStep { Action = new DsfBaseConvertActivity { ConvertCollection = convertCollection } }; result = ExecuteProcess(); IList <IBinaryDataListEntry> actual = bdl.FetchRecordsetEntries(); var index = actual[0].FetchRecordAt(5, out error)[0].ItemCollectionIndex; var count = actual.Count(); var actualValue = actual[0].FetchRecordAt(5, out error)[0].TheValue; // remove test datalist ;) DataListRemoval(result.DataListID); Assert.AreEqual("01000011010011110100111001010110010001010101001001010100001000000101010001001000010010010101001100100000010101000100111100100000010000100100100101001110010000010101001001011001", actualValue); Assert.AreEqual(1, count); // still only one record Assert.AreEqual(5, index); // and that record has not moved }
public void UpsertWhereListStringExpectUpsertCorrectlyMultipleRecordset() { //------------Setup for test-------------------------- IDataListCompiler compiler = DataListFactory.CreateDataListCompiler(); IDev2DataListUpsertPayloadBuilder <List <string> > toUpsert = Dev2DataListBuilderFactory.CreateStringListDataListUpsertBuilder(); toUpsert.Add("[[rec().f1]]", new List <string> { "test11", "test12" }); toUpsert.Add("[[rec().f2]]", new List <string> { "test21", "test22" }); IBinaryDataList dataList = Dev2BinaryDataListFactory.CreateDataList(); string creationError; dataList.TryCreateRecordsetTemplate("rec", "recset", new List <Dev2Column> { DataListFactory.CreateDev2Column("f1", "f1"), DataListFactory.CreateDev2Column("f2", "f2") }, true, out creationError); ErrorResultTO localErrors; compiler.PushBinaryDataList(dataList.UID, dataList, out localErrors); //------------Execute Test--------------------------- compiler.Upsert(dataList.UID, toUpsert, out _errors); //------------Assert Results------------------------- IList <IBinaryDataListEntry> binaryDataListEntries = dataList.FetchRecordsetEntries(); IBinaryDataListEntry binaryDataListEntry = binaryDataListEntries[0]; string errString; IList <IBinaryDataListItem> binaryDataListItems = binaryDataListEntry.FetchRecordAt(1, out errString); IBinaryDataListItem binaryDataListItem = binaryDataListItems[0]; IBinaryDataListItem binaryDataListItem2 = binaryDataListItems[1]; string theValue = binaryDataListItem.TheValue; Assert.AreEqual("test11", theValue); theValue = binaryDataListItem2.TheValue; Assert.AreEqual("test21", theValue); binaryDataListItems = binaryDataListEntry.FetchRecordAt(2, out errString); binaryDataListItem = binaryDataListItems[0]; binaryDataListItem2 = binaryDataListItems[1]; theValue = binaryDataListItem.TheValue; Assert.AreEqual("test12", theValue); theValue = binaryDataListItem2.TheValue; Assert.AreEqual("test22", theValue); }
/// <summary> /// Gets the outputs. /// </summary> /// <param name="obj">The obj to get outputs for.</param> /// <returns></returns> public static IBinaryDataList GetSimpleOutputs(object obj) { IBinaryDataList binaryDL = Dev2BinaryDataListFactory.CreateDataList(); Type sourceType = obj.GetType(); foreach (PropertyInfo pi in sourceType.GetProperties()) { List <Outputs> listOfInputs = pi.GetCustomAttributes(typeof(Outputs), true).OfType <Outputs>().ToList(); if (listOfInputs.Count > 0) { string error; if (binaryDL.TryCreateScalarTemplate(string.Empty, listOfInputs[0].UserVisibleName, "", true, out error)) { binaryDL.TryCreateScalarValue(pi.GetValue(obj, null).ToString(), listOfInputs[0].UserVisibleName, out error); } } } return(binaryDL); }