Best NBi code snippet using NBi.Core.Transformation.Transformer.Native.Value
InstanceFactoryTest.cs
Source:InstanceFactoryTest.cs
...40 var instances = factory.Instantiate(args);41 Assert.That(instances.Count, Is.EqualTo(5));42 Assert.That(instances.ElementAt(0).Variables.Count, Is.EqualTo(4));43 Assert.That(instances.ElementAt(0).Variables.ContainsKey("main"), Is.True);44 Assert.That(instances.ElementAt(0).Variables["main"].GetValue(), Is.EqualTo("BE_20190101"));45 Assert.That(instances.ElementAt(0).Variables.ContainsKey("first"), Is.True);46 Assert.That(instances.ElementAt(0).Variables["first"].GetValue(), Is.EqualTo("BE"));47 Assert.That(instances.ElementAt(0).Variables.ContainsKey("second"), Is.True);48 Assert.That(instances.ElementAt(0).Variables["second"].GetValue(), Is.EqualTo(new DateTime(2019, 1, 1)));49 Assert.That(instances.ElementAt(0).Variables.ContainsKey("third"), Is.True);50 Assert.That(instances.ElementAt(0).Variables["third"].GetValue(), Is.EqualTo(new DateTime(2019, 1, 8)));51 Assert.That(instances.ElementAt(1).Variables.Count, Is.EqualTo(4));52 Assert.That(instances.ElementAt(1).Variables.ContainsKey("main"), Is.True);53 Assert.That(instances.ElementAt(1).Variables["main"].GetValue(), Is.EqualTo("BE_20190102"));54 Assert.That(instances.ElementAt(1).Variables.ContainsKey("first"), Is.True);55 Assert.That(instances.ElementAt(1).Variables["first"].GetValue(), Is.EqualTo("BE"));56 Assert.That(instances.ElementAt(1).Variables.ContainsKey("second"), Is.True);57 Assert.That(instances.ElementAt(1).Variables["second"].GetValue(), Is.EqualTo(new DateTime(2019, 1, 2)));58 Assert.That(instances.ElementAt(1).Variables.ContainsKey("third"), Is.True);59 Assert.That(instances.ElementAt(1).Variables["third"].GetValue(), Is.EqualTo(new DateTime(2019, 1, 9)));60 }61 }62}...
NativeTransformationfactory.cs
Source:NativeTransformationfactory.cs
...40 functionParameters.Insert(0, ServiceLocator.BasePath);41 var ctor = type.GetConstructors().SingleOrDefault(x => x.GetParameters().Count() == functionParameters.Count());42 if (ctor == null)43 throw new MissingOrUnexpectedParametersTransformationException(className, functionParameters.Count());44 var zip = ctor.GetParameters().Zip(functionParameters, (x, y) => new { x.ParameterType, Value = y });45 var typedFunctionParameters = new List<object>();46 var argsFactory = new ScalarResolverArgsFactory(ServiceLocator, Context);47 var factory = ServiceLocator.GetScalarResolverFactory();48 foreach (var param in zip)49 {50 if (typeof(IScalarResolver).IsAssignableFrom(param.ParameterType))51 {52 53 var scalarType = param.ParameterType.GenericTypeArguments[0];54 var args = argsFactory.Instantiate(param.Value);55 var resolver = factory.Instantiate(args, scalarType);56 typedFunctionParameters.Add(resolver);57 }58 else59 typedFunctionParameters.Add(param.Value);60 }61 return (INativeTransformation)ctor.Invoke(typedFunctionParameters.ToArray());62 }63 }64}...
NativeTransformer.cs
Source:NativeTransformer.cs
...42 if (!IsInitialized)43 throw new InvalidOperationException();44 var factory = new CasterFactory<T>();45 var caster = factory.Instantiate();46 object typedValue;47 if (value == null || value == DBNull.Value || value as string == "(null)")48 typedValue = null;49 else if ((typeof(T) != typeof(string)) && (value is string) && ((string.IsNullOrEmpty(value as string) || value as string == "(empty)")))50 typedValue = null;51 else52 typedValue = caster.Execute(value);53 object transformedValue = typedValue;54 foreach (var transformation in Transformations)55 transformedValue = transformation.Evaluate(transformedValue);56 return transformedValue;57 }58 }59}...
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!