Best NBi code snippet using NBi.Core.Scalar.Resolver.ScalarResolverArgsFactory
ScalarResolverArgsFactoryTest.cs
Source:ScalarResolverArgsFactoryTest.cs
...9using System.Text;10using System.Threading.Tasks;11namespace NBi.Testing.Core.Scalar.Resolver12{13 class ScalarResolverArgsFactoryTest14 {15 [Test]16 public void Instantiate_Literal_LiteralResolverArgs()17 {18 var factory = new ScalarResolverArgsFactory(new ServiceLocator(), null);;19 var args = factory.Instantiate("First day of 2018 is a Monday");20 Assert.That(args, Is.TypeOf<LiteralScalarResolverArgs>());21 }22 [Test]23 public void Instantiate_Format_FormatResolverArgs()24 {25 var factory = new ScalarResolverArgsFactory(new ServiceLocator(), null);;26 var args = factory.Instantiate("~First day of 2018 is a { @myVar: dddd}");27 Assert.That(args, Is.TypeOf<FormatScalarResolverArgs>());28 }29 [Test]30 public void Instantiate_Variable_GlobalVariableResolverArgs()31 {32 var factory = new ScalarResolverArgsFactory(new ServiceLocator(), null);;33 var args = factory.Instantiate("@myVar");34 Assert.That(args, Is.TypeOf<GlobalVariableScalarResolverArgs>());35 }36 [Test]37 public void Instantiate_Variable_ContextResolverArgs()38 {39 var factory = new ScalarResolverArgsFactory(new ServiceLocator(), null);;40 var args = factory.Instantiate("[myColumn]");41 Assert.That(args, Is.TypeOf<ContextScalarResolverArgs>());42 }43 [Test]44 public void Instantiate_NativeTransformation_FunctionResolverArgs()45 {46 var factory = new ScalarResolverArgsFactory(new ServiceLocator(), null);;47 var args = factory.Instantiate("@myVar | text-to-length");48 Assert.That(args, Is.TypeOf<FunctionScalarResolverArgs>());49 var typedArgs = args as FunctionScalarResolverArgs;50 Assert.That(typedArgs.Resolver, Is.TypeOf<GlobalVariableScalarResolver<object>>());51 Assert.That(typedArgs.Transformations.Count, Is.EqualTo(1));52 Assert.That(typedArgs.Transformations.ElementAt(0), Is.TypeOf<TextToLength>());53 }54 [Test]55 public void Instantiate_NativeTransformationWithFormat_FunctionResolverArgs()56 {57 var factory = new ScalarResolverArgsFactory(new ServiceLocator(), null);;58 var args = factory.Instantiate("~{@myVar : dddd} | text-to-length");59 Assert.That(args, Is.TypeOf<FunctionScalarResolverArgs>());60 var typedArgs = args as FunctionScalarResolverArgs;61 Assert.That(typedArgs.Resolver, Is.TypeOf<FormatScalarResolver>());62 Assert.That(typedArgs.Transformations.Count, Is.EqualTo(1));63 Assert.That(typedArgs.Transformations.ElementAt(0), Is.TypeOf<TextToLength>());64 }65 [Test]66 public void Instantiate_NativeTransformationInsideFormat_FormatResolverArgs()67 {68 var factory = new ScalarResolverArgsFactory(new ServiceLocator(), null);;69 var args = factory.Instantiate("~{@myVar | dateTime-to-previous-month : dddd} ");70 Assert.That(args, Is.TypeOf<FormatScalarResolverArgs>());71 }72 [Test]73 public void Instantiate_ContextWithFormat_LiteralResolverArgs()74 {75 var factory = new ScalarResolverArgsFactory(new ServiceLocator(), null); ;76 var args = factory.Instantiate("[~{@date:yyyy}]");77 Assert.That(args, Is.TypeOf<ContextScalarResolverArgs>());78 }79 [Test]80 public void Instantiate_LiteralWithGravesAndPipes_LiteralResolverArgs()81 {82 var factory = new ScalarResolverArgsFactory(new ServiceLocator(), null);;83 var args = factory.Instantiate("`a|b|c`");84 Assert.That(args, Is.TypeOf<LiteralScalarResolverArgs>());85 Assert.That((args as LiteralScalarResolverArgs).Object, Is.EqualTo("a|b|c"));86 }87 [Test]88 public void Instantiate_LiteralWithGravesAndBrakets_LiteralResolverArgs()89 {90 var factory = new ScalarResolverArgsFactory(new ServiceLocator(), null); ;91 var args = factory.Instantiate("`[a].[c]`");92 Assert.That(args, Is.TypeOf<LiteralScalarResolverArgs>());93 Assert.That((args as LiteralScalarResolverArgs).Object, Is.EqualTo("[a].[c]"));94 }95 [Test]96 public void Instantiate_MDXParameter_LiteralResolverArgs()97 {98 var factory = new ScalarResolverArgsFactory(new ServiceLocator(), null); ;99 var args = factory.Instantiate("[dimension].[hierarchy].[member]");100 Assert.That(args, Is.TypeOf<LiteralScalarResolverArgs>());101 Assert.That((args as LiteralScalarResolverArgs).Object, Is.EqualTo("[dimension].[hierarchy].[member]"));102 }103 [Test]104 public void Instantiate_ColumnWithBrakets_ContextResolverArgs()105 {106 var factory = new ScalarResolverArgsFactory(new ServiceLocator(), null); ;107 var args = factory.Instantiate("[[schema].[column]]");108 Assert.That(args, Is.TypeOf<ContextScalarResolverArgs>());109 Assert.That((args as ContextScalarResolverArgs).ColumnIdentifier.Label, Is.EqualTo("[[schema].[column]]"));110 }111 }112}...
ScalarResolverArgsFactory.cs
Source:ScalarResolverArgsFactory.cs
...10using System.Text.RegularExpressions;11using System.Threading.Tasks;12namespace NBi.Core.Scalar.Resolver13{14 public class ScalarResolverArgsFactory15 {16 private ServiceLocator ServiceLocator { get; }17 private Context Context { get; }18 public ScalarResolverArgsFactory(ServiceLocator serviceLocator, Context context)19 => (ServiceLocator, Context) = (serviceLocator, context);20 public IScalarResolverArgs Instantiate(string value)21 {22 switch (value)23 {24 case string obj when obj.TrimStart().StartsWith("`") && obj.TrimEnd().EndsWith("`"):25 return new LiteralScalarResolverArgs(obj.Trim().Substring(1, obj.Trim().Length - 2));26 case string obj when string.IsNullOrEmpty(value): return new LiteralScalarResolverArgs(string.Empty);27 case null: return new LiteralScalarResolverArgs(string.Empty);28 default:29 var tokens = Regex.Matches(value, @"(?:(?:\{(?>[^{}]+|\{(?<subpart>)|\}(?<-subpart>))*(?(subpart)(?!))\})|[^|])+").Cast<Match>().Select(x => x.Value.Trim());30 var firstToken = tokens.First().Trim();31 var prefix = tokens.First().Trim().ToCharArray()[0];32 var suffix = tokens.Last().Trim().ToCharArray().Last();...
ScriptOuputStrategy.cs
Source:ScriptOuputStrategy.cs
...24 case LanguageType.NCalc:25 args = new NCalcScalarResolverArgs(script, context);26 break ;27 case LanguageType.Native:28 args = new ScalarResolverArgsFactory(serviceLocator, context).Instantiate(script);29 break;30 default: throw new ArgumentException();31 }32 Resolver = factory.Instantiate(args);33 }34 public object Execute(bool isOriginal, bool isDuplicable, int times, int index)35 => Resolver.Execute();36 public bool IsApplicable(bool isOriginal) => !isOriginal;37 }38}
ScalarResolverArgsFactory
Using AI Code Generation
1using System;2using System.Collections.Generic;3using System.Linq;4using System.Text;5using System.Threading.Tasks;6using NBi.Core.Scalar.Resolver;7{8 {9 public IScalarResolverArgs Instantiate(string value)10 {11 return new FileScalarResolverArgs(value);12 return new EnvironmentScalarResolverArgs(value);13 return new CommandScalarResolverArgs(value);14 return new StringScalarResolverArgs(value);15 return new VariableScalarResolverArgs(value);16 return new ConnectionStringScalarResolverArgs(value);17 return new ConstantScalarResolverArgs(value);18 return new QueryScalarResolverArgs(value);19 return new SqlScalarResolverArgs(value);20 return new XmlScalarResolverArgs(value);21 return new JsonScalarResolverArgs(value);22 return new IniScalarResolverArgs(value);23 return new CsvScalarResolverArgs(value);24 return new XlsScalarResolverArgs(value);25 return new XlsxScalarResolverArgs(value);26 return new OdsScalarResolverArgs(value);27 return new SasScalarResolverArgs(value);28 return new DbScalarResolverArgs(value);29 return new ProjectScalarResolverArgs(value);30 return new SsoScalarResolverArgs(value);31 return new PasswordScalarResolverArgs(value);32 return new KeyScalarResolverArgs(value);33 return new RdsScalarResolverArgs(value);
ScalarResolverArgsFactory
Using AI Code Generation
1using NBi.Core.Scalar.Resolver;2using NBi.Core.Scalar.Resolver.Args;3using System;4using System.Collections.Generic;5using System.Linq;6using System.Text;7using System.Threading.Tasks;8{9 {10 static void Main(string[] args)11 {12 var argsFactory = new ScalarResolverArgsFactory();13 var args = argsFactory.Instantiate("MyValue");14 Console.WriteLine(args.DisplayText);15 Console.ReadLine();16 }17 }18}
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!!