How to use Setup method of NBi.NUnit.Builder.Helper.SequenceResolverArgsBuilder class

Best NBi code snippet using NBi.NUnit.Builder.Helper.SequenceResolverArgsBuilder.Setup

ResultSetResolverArgsBuilder.cs

Source:ResultSetResolverArgsBuilder.cs Github

copy

Full Screen

...27namespace NBi.NUnit.Builder.Helper28{29 class ResultSetResolverArgsBuilder30 {31 private bool isSetup = false;32 private object obj = null;33 private SettingsXml settings = null;34 private SettingsXml.DefaultScope scope = SettingsXml.DefaultScope.Everywhere;35 private IDictionary<string, IVariable> Variables { get; set; } = new Dictionary<string, IVariable>();36 private ResultSetResolverArgs args = null;37 private ServiceLocator ServiceLocator { get; }38 public ResultSetResolverArgsBuilder(ServiceLocator serviceLocator) => this.ServiceLocator = serviceLocator;39 public void Setup(object obj, SettingsXml settingsXml, SettingsXml.DefaultScope scope, IDictionary<string, IVariable> variables)40 {41 this.obj = obj;42 this.settings = settingsXml;43 this.scope = scope;44 this.Variables = variables;45 isSetup = true;46 }47 public void Build()48 {49 if (!isSetup)50 throw new InvalidOperationException();51 switch (obj)52 {53 case ResultSetSystemXml x: args = BuildResultSetSystemXml(x); break;54 case ResultSetXml x: args = BuildResultSetXml(x); break;55 case IfMissingXml x when !(x?.File?.IsEmpty() ?? false): args = BuildFlatFileResultSetResolverArgs(x.File); break;56 case QueryXml x: args = BuildQueryResolverArgs(x, scope); break;57 case XmlSourceXml x: args = BuildXPathResolverArgs(x); break;58 case JsonSourceXml x: args = BuildJsonPathResolverArgs(x); break;59 default: throw new ArgumentException();60 }61 }62 private ResultSetResolverArgs BuildResultSetSystemXml(ResultSetSystemXml xml)63 {64 if (xml?.IfUnavailable?.ResultSet != null)65 return BuildIfUnavaibleResultSetResolverArgs(BuildInternalResultSetSystemXml(xml), BuildResultSetSystemXml(xml.IfUnavailable.ResultSet));66 else67 return BuildInternalResultSetSystemXml(xml);68 }69 private ResultSetResolverArgs BuildInternalResultSetSystemXml(ResultSetSystemXml xml)70 {71 //ResultSet (external flat file)72 if (!xml?.File?.IsEmpty() ?? false)73 return BuildFlatFileResultSetResolverArgs(xml.File);74 //Query75 else if (xml.Query != null)76 return BuildQueryResolverArgs(xml.Query, scope);77 else if (xml.SequenceCombination != null)78 return BuildSequenceCombinationResolverArgs(xml.SequenceCombination);79 else if (xml.Sequence != null)80 return BuildSequenceResolverArgs(xml.Sequence);81 else if (xml.XmlSource != null)82 return BuildXPathResolverArgs(xml.XmlSource);83 else if (xml.JsonSource != null)84 return BuildJsonPathResolverArgs(xml.JsonSource);85 else if (xml.Empty != null)86 return BuildEmptyResolverArgs(xml.Empty);87 else if (xml.Iteration != null)88 return BuildIterativeResultSetResolverArgs(xml.Iteration, xml.NestedResultSet);89 else if (xml.Rows != null)90 return BuildEmbeddedResolverArgs(xml.Content);91 throw new ArgumentException();92 }93 private ResultSetResolverArgs BuildResultSetXml(ResultSetXml xml)94 {95 //ResultSet (external flat file)96 if (!string.IsNullOrEmpty(xml.File))97 {98 ParseFileInfo(xml.File, out var filename, out var parserName);99 if (string.IsNullOrEmpty(parserName))100 return BuildFlatFileResultSetResolverArgs(new FileXml() { Path = filename });101 else102 return BuildFlatFileResultSetResolverArgs(new FileXml() { Path = filename, Parser = new ParserXml() { Name = parserName } });103 }104 //ResultSet (embedded)105 else if (xml.Rows != null)106 return BuildEmbeddedResolverArgs(xml.Content);107 throw new ArgumentException();108 }109 private ResultSetResolverArgs BuildSequenceCombinationResolverArgs(SequenceCombinationXml sequenceCombinationXml)110 {111 var resolvers = new List<ISequenceResolver>();112 var sequenceFactory = new SequenceResolverFactory(ServiceLocator);113 var builder = new SequenceResolverArgsBuilder(ServiceLocator);114 builder.Setup(settings);115 builder.Setup(Variables);116 foreach (var sequenceXml in sequenceCombinationXml.Sequences)117 {118 builder.Setup(sequenceXml.Type);119 builder.Setup((object)sequenceXml.SentinelLoop ?? sequenceXml.Items);120 builder.Build();121 resolvers.Add(sequenceFactory.Instantiate(sequenceXml.Type, builder.GetArgs()));122 }123 return new SequenceCombinationResultSetResolverArgs(resolvers);124 }125 private ResultSetResolverArgs BuildSequenceResolverArgs(SequenceXml sequenceXml)126 {127 var sequenceFactory = new SequenceResolverFactory(ServiceLocator);128 var builder = new SequenceResolverArgsBuilder(ServiceLocator);129 builder.Setup(settings);130 builder.Setup(Variables);131 builder.Setup(sequenceXml.Type);132 builder.Setup((object)sequenceXml.SentinelLoop ?? sequenceXml.Items);133 builder.Build();134 var resolver = sequenceFactory.Instantiate(sequenceXml.Type, builder.GetArgs());135 return new SequenceResultSetResolverArgs(resolver);136 }137 private void ParseFileInfo(string input, out string filename, out string parserName)138 {139 var split = input.Split(new char[] { '!' }, StringSplitOptions.RemoveEmptyEntries);140 filename = split[0];141 parserName = split.Count() == 1 ? string.Empty : split[1];142 }143 private ResultSetResolverArgs BuildEmbeddedResolverArgs(IContent content)144 {145 Trace.WriteLineIf(Extensibility.NBiTraceSwitch.TraceVerbose, "ResultSet defined in embedded resultSet.");146 return new ContentResultSetResolverArgs(content);147 }148 private ResultSetResolverArgs BuildIterativeResultSetResolverArgs(IterationXml iterationXml, ResultSetSystemXml nestedResultSetXml)149 {150 var sequenceFactory = new SequenceResolverFactory(ServiceLocator);151 var builder = new SequenceResolverArgsBuilder(ServiceLocator);152 builder.Setup(settings);153 builder.Setup(Variables);154 builder.Setup(iterationXml.Sequence.Type);155 builder.Setup((object)iterationXml.Sequence.SentinelLoop ?? iterationXml.Sequence.Items);156 builder.Build();157 var sequenceResolver = sequenceFactory.Instantiate(iterationXml.Sequence.Type, builder.GetArgs());158 var nestedHelper = new ResultSetSystemHelper(ServiceLocator, scope, Variables);159 nestedResultSetXml.Settings = settings;160 var nestedResultSetResolver = nestedHelper.InstantiateResolver(nestedResultSetXml);161 return new IterativeResultSetResolverArgs(sequenceResolver, iterationXml.Sequence.Name, Variables, nestedResultSetResolver);162 }163 private ResultSetResolverArgs BuildQueryResolverArgs(QueryXml queryXml, SettingsXml.DefaultScope scope)164 {165 Trace.WriteLineIf(Extensibility.NBiTraceSwitch.TraceVerbose, "ResultSet defined through a query.");166 var argsBuilder = new QueryResolverArgsBuilder(ServiceLocator);167 argsBuilder.Setup(queryXml, settings, scope, Variables);168 argsBuilder.Build();169 var argsQuery = argsBuilder.GetArgs();170 return new QueryResultSetResolverArgs(argsQuery);171 }172 private ResultSetResolverArgs BuildFlatFileResultSetResolverArgs(FileXml fileMetadata)173 {174 Trace.WriteLineIf(Extensibility.NBiTraceSwitch.TraceVerbose, $"ResultSet defined in an external flat file to be read with {(string.IsNullOrEmpty(fileMetadata.Parser?.Name) ? "the default CSV parser" : fileMetadata.Parser?.Name)}.");175 var helper = new ScalarHelper(ServiceLocator, settings, scope, new Context(Variables));176 var resolverPath = helper.InstantiateResolver<string>(fileMetadata.Path);177 if (fileMetadata.IfMissing == null)178 return new FlatFileResultSetResolverArgs(resolverPath, settings?.BasePath, fileMetadata.Parser?.Name, settings?.CsvProfile);179 var builder = new ResultSetResolverArgsBuilder(ServiceLocator);180 builder.Setup(fileMetadata.IfMissing, settings, scope, Variables);181 builder.Build();182 var redirection = builder.GetArgs();183 var factory = new ResultSetResolverFactory(ServiceLocator);184 var resolver = factory.Instantiate(redirection);185 return new FlatFileResultSetResolverArgs(resolverPath, settings?.BasePath, fileMetadata.Parser?.Name, resolver, settings?.CsvProfile);186 }187 private ResultSetResolverArgs BuildXPathResolverArgs(XmlSourceXml xmlSource)188 {189 Trace.WriteLineIf(Extensibility.NBiTraceSwitch.TraceVerbose, "ResultSet defined through an xml-source.");190 var helper = new ScalarHelper(ServiceLocator, settings, scope, new Context(Variables));191 IReaderArgs reader = null;192 if (xmlSource.File != null)193 {194 var resolverPath = helper.InstantiateResolver<string>(xmlSource.File.Path);195 reader = new FileReaderArgs(settings?.BasePath, resolverPath);196 }197 else if (xmlSource.Url != null)198 {199 var resolverUrl = helper.InstantiateResolver<string>(xmlSource.Url.Value);200 reader = new UrlReaderArgs(resolverUrl);201 }202 else if (xmlSource.Rest != null)203 {204 var restHelper = new RestHelper(ServiceLocator, settings, scope, Variables);205 reader = new RestReaderArgs(restHelper.Execute(xmlSource.Rest));206 }207 var selects = new List<IPathSelect>();208 var selectFactory = new PathFlattenizerFactory();209 foreach (var select in xmlSource.XPath.Selects)210 selects.Add(selectFactory.Instantiate(helper.InstantiateResolver<string>(select.Value), select.Attribute, select.Evaluate));211 var flattenizer = new XPathArgs212 {213 From = helper.InstantiateResolver<string>(xmlSource.XPath.From.Value),214 Selects = selects,215 DefaultNamespacePrefix = xmlSource.XPath?.DefaultNamespacePrefix,216 IsIgnoreNamespace = xmlSource.IgnoreNamespace217 };218 return new DataSerializationResultSetResolverArgs(reader, flattenizer);219 }220 private ResultSetResolverArgs BuildJsonPathResolverArgs(JsonSourceXml jsonSource)221 {222 Trace.WriteLineIf(Extensibility.NBiTraceSwitch.TraceVerbose, "ResultSet defined through an json-source.");223 var context = new Context(Variables);224 var helper = new ScalarHelper(ServiceLocator, settings, scope, context);225 IReaderArgs reader = null;226 if (jsonSource.File != null)227 {228 var resolverPath = helper.InstantiateResolver<string>(jsonSource.File.Path);229 reader = new FileReaderArgs(settings?.BasePath, resolverPath);230 }231 else if (jsonSource.Url != null)232 {233 var resolverUrl = helper.InstantiateResolver<string>(jsonSource.Url.Value);234 reader = new UrlReaderArgs(resolverUrl);235 }236 else if (jsonSource.Rest != null)237 {238 var restHelper = new RestHelper(ServiceLocator, settings, scope, Variables);239 reader = new RestReaderArgs(restHelper.Execute(jsonSource.Rest));240 }241 else if (jsonSource.QueryScalar != null)242 {243 var builder = new ScalarResolverArgsBuilder(ServiceLocator, context);244 builder.Setup(jsonSource.QueryScalar, settings, scope);245 builder.Build();246 var args = ServiceLocator.GetScalarResolverFactory().Instantiate<string>(builder.GetArgs());247 reader = new ScalarReaderArgs(args);248 }249 var selects = new List<IPathSelect>();250 var selectFactory = new PathFlattenizerFactory();251 foreach (var select in jsonSource.JsonPath.Selects)252 selects.Add(selectFactory.Instantiate(helper.InstantiateResolver<string>(select.Value), string.Empty, false));253 var flattenizer = new JsonPathArgs254 {255 From = helper.InstantiateResolver<string>(jsonSource.JsonPath.From.Value),256 Selects = selects,257 };258 return new DataSerializationResultSetResolverArgs(reader, flattenizer);...

Full Screen

Full Screen

InstanceArgsBuilder.cs

Source:InstanceArgsBuilder.cs Github

copy

Full Screen

...21 public class InstanceArgsBuilder22 {23 private ServiceLocator ServiceLocator { get; }24 private IDictionary<string, IVariable> Variables { get; }25 private bool isSetup = false;26 private object obj = null;27 private SettingsXml settings = SettingsXml.Empty;28 private IInstanceArgs args = null;29 public InstanceArgsBuilder(ServiceLocator serviceLocator, IDictionary<string, IVariable> variables)30 => (ServiceLocator, Variables) = (serviceLocator, variables);31 public void Setup(SettingsXml settings)32 {33 this.settings = settings;34 }35 public void Setup(InstanceSettlingXml definition)36 {37 obj = definition;38 isSetup = true;39 }40 public void Build()41 {42 if (!isSetup)43 throw new InvalidOperationException();44 if (obj == InstanceSettlingXml.Unique)45 args = new DefaultInstanceArgs();46 else if ((obj as InstanceSettlingXml).Variable != null)47 {48 var variable = (obj as InstanceSettlingXml).Variable;49 var argsBuilder = new SequenceResolverArgsBuilder(ServiceLocator);50 argsBuilder.Setup(settings);51 argsBuilder.Setup(Variables);52 argsBuilder.Setup(variable.Type);53 if (variable.SentinelLoop != null)54 argsBuilder.Setup(variable.SentinelLoop);55 else if (variable.FileLoop != null)56 argsBuilder.Setup(variable.FileLoop);57 else if (variable.Custom != null)58 argsBuilder.Setup(variable.Custom);59 else if (variable.Query != null)60 argsBuilder.Setup(variable.Query);61 else if (variable.Items != null && variable.Items.Count>0)62 argsBuilder.Setup(variable.Items);63 else64 throw new ArgumentOutOfRangeException();65 argsBuilder.Build();66 var factory = new SequenceResolverFactory(ServiceLocator);67 var innerResolver = factory.Instantiate(variable.Type, argsBuilder.GetArgs());68 var sequenceResolver = BuildFilterSequenceResolver(variable.Type, innerResolver, variable.Filter);69 if (((obj as InstanceSettlingXml).DerivedVariables?.Count() ?? 0) == 0)70 {71 args = new SingleVariableInstanceArgs()72 {73 Name = variable.Name,74 Resolver = sequenceResolver,75 Categories = (obj as InstanceSettlingXml).Categories,76 Traits = (obj as InstanceSettlingXml).Traits.ToDictionary(x => x.Name, x => x.Value),...

Full Screen

Full Screen

SequenceResolverArgsBuilder.cs

Source:SequenceResolverArgsBuilder.cs Github

copy

Full Screen

...20namespace NBi.NUnit.Builder.Helper21{22 class SequenceResolverArgsBuilder23 {24 private bool isSetup = false;25 private object obj = null;26 private SettingsXml settings = null;27 private IDictionary<string, IVariable> Variables { get; set; } = new Dictionary<string, IVariable>();28 private SettingsXml.DefaultScope Scope { get; } = SettingsXml.DefaultScope.Everywhere;29 private ISequenceResolverArgs Args { get; set; } = null;30 private ColumnType columnType = ColumnType.Numeric;31 private ServiceLocator ServiceLocator { get; }32 public SequenceResolverArgsBuilder(ServiceLocator serviceLocator)33 => ServiceLocator = serviceLocator;34 public void Setup(object obj)35 {36 this.obj = obj;37 isSetup = true;38 }39 public void Setup(ColumnType columnType)40 {41 this.columnType = columnType;42 }43 public void Setup(SettingsXml settingsXml)44 {45 this.settings = settingsXml;46 }47 public void Setup(IDictionary<string, IVariable> globalVariables)48 {49 this.Variables = globalVariables;50 }51 public void Build()52 {53 if (!isSetup)54 throw new InvalidOperationException();55 var helper = new ScalarHelper(ServiceLocator, new Context(Variables));56 switch (obj)57 {58 case SentinelLoopXml loop:59 switch (columnType)60 {61 case ColumnType.Numeric:62 Args = BuildSentinelLoopResolverArgs<decimal, decimal>(loop.Seed, loop.Terminal, loop.Step, loop.IntervalMode);63 break;64 case ColumnType.DateTime:65 Args = BuildSentinelLoopResolverArgs<DateTime, IDuration>(loop.Seed, loop.Terminal, loop.Step, loop.IntervalMode);66 break;67 default:68 throw new ArgumentOutOfRangeException();69 }70 break;71 case FileLoopXml loop:72 Args = BuildFileLoopResolverArgs(loop.Path, loop.Pattern);73 break;74 case QueryXml query:75 var queryBuilder = new QueryResolverArgsBuilder(ServiceLocator);76 queryBuilder.Setup(query, settings, Scope, Variables);77 queryBuilder.Build();78 Args = new QuerySequenceResolverArgs(queryBuilder.GetArgs());79 break;80 case CustomXml obj:81 Args = new CustomSequenceResolverArgs(82 helper.InstantiateResolver<string>(obj.AssemblyPath),83 helper.InstantiateResolver<string>(obj.TypeName),84 obj.Parameters.Select(x => new { x.Name, ScalarResolver = (IScalarResolver)helper.InstantiateResolver<string>(x.StringValue) })85 .ToDictionary(x => x.Name, y => y.ScalarResolver)86 );87 break;88 case List<string> list:89 var resolvers = new List<IScalarResolver>();90 foreach (var value in list)...

Full Screen

Full Screen

Setup

Using AI Code Generation

copy

Full Screen

1using NBi.NUnit.Builder.Helper;2using NUnit.Framework;3using System;4using System.Collections.Generic;5using System.Linq;6using System.Text;7using System.Threading.Tasks;8{9 {10 public void Setup_WithValidString_ReturnsSequenceResolverArgsWithCorrectValues()11 {12 var builder = new SequenceResolverArgsBuilder();13 string input = "1,2,3";14 var result = builder.Setup(input);15 Assert.That(result.Sequence, Is.EquivalentTo(new[] { 1, 2, 3 }));16 }17 }18}

Full Screen

Full Screen

Setup

Using AI Code Generation

copy

Full Screen

1var args = new NBi.NUnit.Builder.Helper.SequenceResolverArgsBuilder();2args.Setup("1,2,3,4,5,6,7,8,9,10");3var resolver = new NBi.NUnit.Builder.Helper.SequenceResolver(args.GetArgs());4var sequence = resolver.Execute();5var args = new NBi.NUnit.Builder.Helper.SequenceResolverArgsBuilder();6args.Setup("1,2,3,4,5,6,7,8,9,10");7var resolver = new NBi.NUnit.Builder.Helper.SequenceResolver(args.GetArgs());8var sequence = resolver.Execute();9var args = new NBi.NUnit.Builder.Helper.SequenceResolverArgsBuilder();10args.Setup("1,2,3,4,5,6,7,8,9,10");11var resolver = new NBi.NUnit.Builder.Helper.SequenceResolver(args.GetArgs());12var sequence = resolver.Execute();13var args = new NBi.NUnit.Builder.Helper.SequenceResolverArgsBuilder();14args.Setup("1,2,3,4,5,6,7,8,9,10");15var resolver = new NBi.NUnit.Builder.Helper.SequenceResolver(args.GetArgs());16var sequence = resolver.Execute();17var args = new NBi.NUnit.Builder.Helper.SequenceResolverArgsBuilder();18args.Setup("1,2,3,4,5,6,7,8,9,10");19var resolver = new NBi.NUnit.Builder.Helper.SequenceResolver(args.GetArgs());20var sequence = resolver.Execute();21var args = new NBi.NUnit.Builder.Helper.SequenceResolverArgsBuilder();22args.Setup("1,2,3,4,5,6,7,8,9,10");23var resolver = new NBi.NUnit.Builder.Helper.SequenceResolver(args.GetArgs());24var sequence = resolver.Execute();

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 method in SequenceResolverArgsBuilder

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful