How to use TransformerFactory class of NBi.Core.Transformation package

Best NBi code snippet using NBi.Core.Transformation.TransformerFactory

InstanceArgsBuilder.cs

Source: InstanceArgsBuilder.cs Github

copy

Full Screen

...81 var derivationArgs = new Dictionary<string, DerivationArgs>();82 foreach (var derivation in (obj as InstanceSettlingXml).DerivedVariables)83 {84 var transformerArgs = new TransformaterArgs() { Language = derivation.Script.Language, Code = derivation.Script.Code };85 var transformerFactory = new TransformerFactory(ServiceLocator, new Context(Variables));86 var transformer = transformerFactory.Instantiate(transformerArgs);87 transformer.Initialize(derivation.Script.Code);88 derivationArgs.Add(derivation.Name, new DerivationArgs() { Source = derivation.BasedOn, Transformer = transformer });89 }90 args = new DerivedVariableInstanceArgs()91 {92 Name = variable.Name,93 Resolver = sequenceResolver,94 Derivations = derivationArgs,95 Categories = (obj as InstanceSettlingXml).Categories,96 Traits = (obj as InstanceSettlingXml).Traits.ToDictionary(x => x.Name, x => x.Value),97 };98 }99 }100 }101 private ISequenceResolver BuildFilterSequenceResolver(ColumnType type, ISequenceResolver resolver, FilterSequenceXml filterXml)102 {103 if (filterXml == null)104 return resolver;105 var predicateBuilder = new PredicateArgsBuilder(ServiceLocator, new Context(Variables));106 var predicateArgs = predicateBuilder.Execute(filterXml.Predication.ColumnType, filterXml.Predication.Predicate);107 var predicate = new PredicateFactory().Instantiate(predicateArgs);108 var operandTransformation = new TransformerFactory(ServiceLocator, new Context(Variables)).Instantiate109 (110 new OperandTransformation111 {112 OriginalType = type,113 Code = filterXml.Predication.Operand114 }115 );116 operandTransformation.Initialize(filterXml.Predication.Operand);117 var factory = new SequenceResolverFactory(ServiceLocator);118 return factory.Instantiate(type, new FilterSequenceResolverArgs(resolver, predicate, operandTransformation));119 }120 private class OperandTransformation : ITransformationInfo121 {122 public ColumnType OriginalType { get ; set; }...

Full Screen

Full Screen

TransformerFactoryTest.cs

Source: TransformerFactoryTest.cs Github

copy

Full Screen

...11using NBi.Core.Injection;12namespace NBi.Testing.Core.Transformation13{14 [TestFixture]15 public class TransformerFactoryTest16 {17 [Test]18 [TestCase(LanguageType.CSharp, typeof(CSharpTransformer<decimal>))]19 [TestCase(LanguageType.NCalc, typeof(NCalcTransformer<decimal>))]20 [TestCase(LanguageType.Format, typeof(FormatTransformer<decimal>))]21 [TestCase(LanguageType.Native, typeof(NativeTransformer<decimal>))]22 public void Build_Language_Correct(LanguageType language, Type result)23 {24 var info = Mock.Of<ITransformationInfo>25 (26 i => i.Language == language27 && i.OriginalType == ColumnType.Numeric28 && i.Code == "value" 29 );30 var factory = new TransformerFactory(new ServiceLocator(), null);31 var provider = factory.Instantiate(info);32 Assert.IsInstanceOf(result, provider);33 }34 [Test]35 [TestCase(ColumnType.Text, typeof(CSharpTransformer<string>))]36 [TestCase(ColumnType.Numeric, typeof(CSharpTransformer<decimal>))]37 [TestCase(ColumnType.DateTime, typeof(CSharpTransformer<DateTime>))]38 [TestCase(ColumnType.Boolean, typeof(CSharpTransformer<bool>))]39 public void Build_Language_Correct(ColumnType originalType, Type result)40 {41 var info = Mock.Of<ITransformationInfo>42 (43 i => i.Language == LanguageType.CSharp44 && i.OriginalType == originalType45 && i.Code == "value"46 );47 var factory = new TransformerFactory(new ServiceLocator(), null);48 var provider = factory.Instantiate(info);49 Assert.IsInstanceOf(result, provider);50 }51 [Test]52 [TestCase(LanguageType.NCalc, ColumnType.DateTime)]53 [TestCase(LanguageType.NCalc, ColumnType.Boolean)]54 [TestCase(LanguageType.Format, ColumnType.Text)]55 [TestCase(LanguageType.Format, ColumnType.Boolean)]56 public void Build_Language_Correct(LanguageType language, ColumnType columnType)57 {58 var info = Mock.Of<ITransformationInfo>59 (60 i => i.Language == language61 && i.OriginalType == columnType62 && i.Code == "value"63 );64 var factory = new TransformerFactory(new ServiceLocator(), null);65 Assert.Throws<InvalidOperationException>(delegate { factory.Instantiate(info); });66 }67 }68}...

Full Screen

Full Screen

TransformationProvider.cs

Source: TransformationProvider.cs Github

copy

Full Screen

...13{14 public class TransformationProvider15 {16 private IDictionary<IColumnIdentifier, ITransformer> cacheTransformers;17 private readonly TransformerFactory factory;18 private Context Context { get; }19 public TransformationProvider(ServiceLocator serviceLocator, Context context)20 {21 cacheTransformers = new Dictionary<IColumnIdentifier, ITransformer>();22 factory = new TransformerFactory(serviceLocator, context);23 Context = context;24 }25 public void Add(IColumnIdentifier indentifier, ITransformationInfo transfo)26 {27 var transformer = factory.Instantiate(transfo);28 transformer.Initialize(transfo.Code);29 if (cacheTransformers.ContainsKey(indentifier))30 throw new NBiException($"You can't define two transformers for the same column. The column {indentifier.Label} has already another transformer specified.");31 cacheTransformers.Add(indentifier, transformer);32 }33 public virtual IResultSet Transform(IResultSet resultSet)34 {35 foreach (var identifier in cacheTransformers.Keys)36 {...

Full Screen

Full Screen

TransformerFactory

Using AI Code Generation

copy

Full Screen

1using System;2using System.Collections.Generic;3using System.Linq;4using System.Text;5using System.Threading.Tasks;6using NBi.Core.Transformation;7using NBi.Core.Transformation.Transformer.Native;8{9 {10 static void Main(string[] args)11 {12 var factory = new TransformerFactory();13 var transformer = factory.Instantiate(new TransformerArgs("Native", "ToUpper"));14 var result = transformer.Execute("nbi");15 Console.WriteLine(result);16 }17 }18}

Full Screen

Full Screen

Blogs

Check out the latest blogs from LambdaTest on this topic:

Six Agile Team Behaviors to Consider

Are members of agile teams different from members of other teams? Both yes and no. Yes, because some of the behaviors we observe in agile teams are more distinct than in non-agile teams. And no, because we are talking about individuals!

QA Innovation &#8211; Using the senseshaping concept to discover customer needs

QA Innovation - Using the senseshaping concept to discover customer needsQA testers have a unique role and responsibility to serve the customer. Serving the customer in software testing means protecting customers from application defects, failures, and perceived failures from missing or misunderstood requirements. Testing for known requirements based on documentation or discussion is the core of the testing profession. One unique way QA testers can both differentiate themselves and be innovative occurs when senseshaping is used to improve the application user experience.

Webinar: Building Selenium Automation Framework [Voices of Community]

Even though several frameworks are available in the market for automation testing, Selenium is one of the most renowned open-source frameworks used by experts due to its numerous features and benefits.

Are Agile Self-Managing Teams Realistic with Layered Management?

Agile software development stems from a philosophy that being agile means creating and responding to change swiftly. Agile means having the ability to adapt and respond to change without dissolving into chaos. Being Agile involves teamwork built on diverse capabilities, skills, and talents. Team members include both the business and software development sides working together to produce working software that meets or exceeds customer expectations continuously.

Fault-Based Testing and the Pesticide Paradox

In some sense, testing can be more difficult than coding, as validating the efficiency of the test cases (i.e., the ‘goodness’ of your tests) can be much harder than validating code correctness. In practice, the tests are just executed without any validation beyond the pass/fail verdict. On the contrary, the code is (hopefully) always validated by testing. By designing and executing the test cases the result is that some tests have passed, and some others have failed. Testers do not know much about how many bugs remain in the code, nor about their bug-revealing efficiency.

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 TransformerFactory

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful