How to use ConverterEngine class of NBi.Core.ResultSet.Conversion package

Best NBi code snippet using NBi.Core.ResultSet.Conversion.ConverterEngine

ResultSetSystemHelper.cs

Source:ResultSetSystemHelper.cs Github

copy

Full Screen

...168 private Alter InstantiateConvert(ConvertXml convertXml)169 {170 var factory = new ConverterFactory();171 var converter = factory.Instantiate(convertXml.Converter.From, convertXml.Converter.To, convertXml.Converter.DefaultValue, convertXml.Converter.Culture);172 var engine = new ConverterEngine(convertXml.Column, converter);173 return engine.Execute;174 }175 private Alter InstantiateRename(RenamingXml renameXml)176 {177 var helper = new ScalarHelper(ServiceLocator, new Context(Variables));178 var newName = helper.InstantiateResolver<string>(renameXml.NewName);179 IMissingColumnStrategy strategy = new FailureMissingColumnStrategy();180 switch (renameXml.Missing.Behavior)181 {182 case alt.Renaming.MissingColumnBehavior.Skip:183 strategy = new SkipAlterationStrategy();184 break;185 default:186 strategy = new FailureMissingColumnStrategy();...

Full Screen

Full Screen

ConverterEngineTest.cs

Source:ConverterEngineTest.cs Github

copy

Full Screen

...9using System.Text;10using System.Threading.Tasks;11namespace NBi.Testing.Core.ResultSet.Conversion12{13 public class ConverterEngineTest14 {15 [Test]16 public void Execute_FirstColumnIsText_FirstColumnIsNumeric()17 {18 var args = new ObjectsResultSetResolverArgs(new[] { new[] { "100,12", "Alpha" }, new[] { "100", "Beta" }, new[] { "0,1", "Gamma" } });19 var resolver = new ObjectsResultSetResolver(args);20 var rs = resolver.Execute();21 var factory = new ConverterFactory();22 var converter = factory.Instantiate("text", "numeric", null, "fr-fr");23 Assert.That(converter, Is.Not.Null);24 Assert.That(converter, Is.TypeOf<TextToNumericConverter>());25 var engine = new ConverterEngine("#0", converter);26 engine.Execute(rs);27 Assert.That(rs.Columns[0].DataType, Is.EqualTo(typeof(decimal)));28 Assert.That(rs.Columns.Count, Is.EqualTo(2));29 Assert.That(rs.Rows[0][0], Is.EqualTo(100.12));30 Assert.That(rs.Rows[1][0], Is.EqualTo(100));31 Assert.That(rs.Rows[2][0], Is.EqualTo(0.1));32 }33 [Test]34 public void Execute_LastColumnIsText_LastColumnIsNumeric()35 {36 var args = new ObjectsResultSetResolverArgs(new[] { new[] { "Alpha", "100,12" }, new[] { "Beta", "100" }, new[] { "Gamma", "0,1" } });37 var resolver = new ObjectsResultSetResolver(args);38 var rs = resolver.Execute();39 var factory = new ConverterFactory();40 var converter = factory.Instantiate("text", "numeric", null, "fr-fr");41 Assert.That(converter, Is.Not.Null);42 Assert.That(converter, Is.TypeOf<TextToNumericConverter>());43 var engine = new ConverterEngine("#1", converter);44 engine.Execute(rs);45 Assert.That(rs.Columns[1].DataType, Is.EqualTo(typeof(decimal)));46 Assert.That(rs.Columns.Count, Is.EqualTo(2));47 Assert.That(rs.Rows[0][1], Is.EqualTo(100.12));48 Assert.That(rs.Rows[1][1], Is.EqualTo(100));49 Assert.That(rs.Rows[2][1], Is.EqualTo(0.1));50 }51 [Test]52 public void Execute_MiddleColumnIsText_MiddleColumnIsNumeric()53 {54 var args = new ObjectsResultSetResolverArgs(new[] { new[] { "Alpha", "100,12", "true" }, new[] { "Beta", "100", "false" }, new[] { "Gamma", "N/A", "false" } });55 var resolver = new ObjectsResultSetResolver(args);56 var rs = resolver.Execute();57 var factory = new ConverterFactory();58 var converter = factory.Instantiate("text", "numeric", null, "fr-fr");59 Assert.That(converter, Is.Not.Null);60 Assert.That(converter, Is.TypeOf<TextToNumericConverter>());61 var engine = new ConverterEngine("#1", converter);62 engine.Execute(rs);63 Assert.That(rs.Columns[1].DataType, Is.EqualTo(typeof(decimal)));64 Assert.That(rs.Columns.Count, Is.EqualTo(3));65 Assert.That(rs.Rows[0][1], Is.EqualTo(100.12));66 Assert.That(rs.Rows[1][1], Is.EqualTo(100));67 Assert.That(rs.Rows[2][1], Is.EqualTo(DBNull.Value));68 }69 [Test]70 public void Execute_MiddleColumnIsTextualDate_MiddleColumnIsDate()71 {72 var args = new ObjectsResultSetResolverArgs(new[] { new[] { "Alpha", "06/01/2018", "true" }, new[] { "Beta", "17/12/2015", "false" }, new[] { "Gamma", "Before 2014", "false" } });73 var resolver = new ObjectsResultSetResolver(args);74 var rs = resolver.Execute();75 var factory = new ConverterFactory();76 var converter = factory.Instantiate("text", "date", new DateTime(2013,1,1), "fr-fr");77 Assert.That(converter, Is.Not.Null);78 Assert.That(converter, Is.TypeOf<TextToDateConverter>());79 var engine = new ConverterEngine("#1", converter);80 engine.Execute(rs);81 Assert.That(rs.Columns[1].DataType, Is.EqualTo(typeof(DateTime)));82 Assert.That(rs.Columns.Count, Is.EqualTo(3));83 Assert.That(rs.Rows[0][1], Is.EqualTo(new DateTime(2018,1,6)));84 Assert.That(rs.Rows[1][1], Is.EqualTo(new DateTime(2015, 12, 17)));85 Assert.That(rs.Rows[2][1], Is.EqualTo(new DateTime(2013, 1, 1)));86 }87 [Test]88 public void Execute_MiddleColumnIsTextualDateTime_MiddleColumnIsDateTime()89 {90 var args = new ObjectsResultSetResolverArgs(new[] { new[] { "Alpha", "06/01/2018 08:12:00", "true" }, new[] { "Beta", "17/12/2015 08:12:00", "false" }, new[] { "Gamma", "Before 2014", "false" } });91 var resolver = new ObjectsResultSetResolver(args);92 var rs = resolver.Execute();93 var factory = new ConverterFactory();94 var converter = factory.Instantiate("text", "dateTime", new DateTime(2019, 12, 31, 23, 59, 59), "fr-fr");95 Assert.That(converter, Is.Not.Null);96 Assert.That(converter, Is.TypeOf<TextToDateTimeConverter>());97 var engine = new ConverterEngine("#1", converter);98 engine.Execute(rs);99 Assert.That(rs.Columns[1].DataType, Is.EqualTo(typeof(DateTime)));100 Assert.That(rs.Columns.Count, Is.EqualTo(3));101 Assert.That(rs.Rows[0][1], Is.EqualTo(new DateTime(2018, 1, 6, 8,12,0)));102 Assert.That(rs.Rows[1][1], Is.EqualTo(new DateTime(2015, 12, 17, 8, 12, 0)));103 Assert.That(rs.Rows[2][1], Is.EqualTo(new DateTime(2019, 12, 31, 23, 59, 59)));104 }105 }106}...

Full Screen

Full Screen

ConverterEngine.cs

Source:ConverterEngine.cs Github

copy

Full Screen

...7using System.Text;8using System.Threading.Tasks;9namespace NBi.Core.ResultSet.Conversion10{11 public class ConverterEngine12 {13 private readonly string column;14 private readonly IConverter converter;15 public ConverterEngine(string column, IConverter converter)16 {17 this.column = !string.IsNullOrEmpty(column) ? column : throw new ArgumentException("The column can't be empty. You should specify the name of the column or the index preceded by a #.", nameof(column));18 this.converter = converter ?? throw new ArgumentNullException("The converter can't be null.", nameof(converter));19 }20 public IResultSet Execute(IResultSet rs)21 {22 var columnName = column.StartsWith("#") ? rs.Columns[Convert.ToInt32(column.Replace("#", ""))].ColumnName : column;23 var columnIndex = column.StartsWith("#") ? Convert.ToInt32(column.Replace("#", "")) : rs.Columns[columnName].Ordinal;24 var columnNameTemp = columnName + "__temp";25 rs.Columns.Add(new DataColumn(columnNameTemp, converter.DestinationType));26 rs.Columns[columnNameTemp].SetOrdinal(columnIndex + 1);27 foreach(DataRow row in rs.Rows)28 row[columnNameTemp] = converter.Execute(row[columnIndex]) ?? DBNull.Value;29 rs.Columns.RemoveAt(columnIndex);...

Full Screen

Full Screen

ConverterEngine

Using AI Code Generation

copy

Full Screen

1var converter = new ConverterEngine();2var result = converter.Convert(new List<Row> {new Row(new List<IContent>{new IntegerContent(1)})});3var result = new ResultSet();4result.Load(new List<Row> {new Row(new List<IContent>{new IntegerContent(1)})});5var converter = new ConverterEngine();6var result = converter.Convert(new List<Row> {new Row(new List<IContent>{new IntegerContent(1)})});7var dataTable = new DataTable();8The type or namespace name 'DataTable' does not exist in the namespace 'NBi.Core.ResultSet' (are you missing an assembly reference?)9using System;10using System.Collections.Generic;11using System.Linq;12using System.Text;13using System.Threading.Tasks;14using NBi.Core.ResultSet;15using NBi.Core.ResultSet.Conversion;

Full Screen

Full Screen

ConverterEngine

Using AI Code Generation

copy

Full Screen

1var converterEngine = new ConverterEngine();2var dataReader = new DataReader();3var result = converterEngine.Convert(dataReader, "1.csv", "csv", "xml");4var reader = new ResultSetReader();5var result = reader.Read("1.csv", "csv");6var reader = new ResultSetReader();7var result = reader.Read("1.xml", "xml");8var reader = new ResultSetReader();9var result = reader.Read("1.txt", "txt");10var reader = new ResultSetReader();11var result = reader.Read("1.txt", "txt");12var reader = new ResultSetReader();13var result = reader.Read("1.txt", "txt");14var reader = new ResultSetReader();15var result = reader.Read("1.txt", "txt");16var reader = new ResultSetReader();17var result = reader.Read("1.txt", "txt");18var reader = new ResultSetReader();19var result = reader.Read("1.txt", "txt");20var reader = new ResultSetReader();21var result = reader.Read("1.txt", "txt");22var reader = new ResultSetReader();23var result = reader.Read("1.txt", "txt");24var reader = new ResultSetReader();25var result = reader.Read("1.txt", "txt");26var reader = new ResultSetReader();27var result = reader.Read("1

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run NBi automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Most used methods in ConverterEngine

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful