Best NBi code snippet using NBi.Core.Query.Resolver.ExternalFileQueryResolver.ExternalFileQueryResolver
ExternalFileQueryResolverTest.cs
Source:ExternalFileQueryResolverTest.cs
...13using NBi.Extensibility;14namespace NBi.Testing.Integration.Core.Query.Resolver15{16 [TestFixture]17 public class ExternalFileQueryResolverTest18 {19 private ExternalFileQueryResolverArgs BuildArgs()20 {21 return new ExternalFileQueryResolverArgs(22 @"Integration\Core\Resources\query.sql",23 ConnectionStringReader.GetSqlClient(),24 new List<IQueryParameter>() { new QueryParameter("param", "10") },25 new List<IQueryTemplateVariable>() { new QueryTemplateVariableXml() { Name = "operator", Value = "not in" } },26 new TimeSpan(0, 0, 10));27 }28 [Test]29 public void Execute_Args_CommandInstantiated()30 {31 var resolver = new ExternalFileQueryResolver(BuildArgs());32 var cmd = resolver.Execute();33 Assert.That(cmd, Is.Not.Null);34 }35 [Test]36 public void Execute_Args_ConnectionStringAssigned()37 {38 var resolver = new ExternalFileQueryResolver(BuildArgs());39 var query = resolver.Execute();40 Assert.That(query.ConnectionString, Is.Not.Null.And.Not.Empty);41 Assert.That(query.ConnectionString, Is.EqualTo(ConnectionStringReader.GetSqlClient()));42 }43 [Test]44 public void Execute_Args_CommandTextAssigned()45 {46 var resolver = new ExternalFileQueryResolver(BuildArgs());47 var query = resolver.Execute();48 Assert.That(query.Statement, Is.EqualTo("select * from myTable;"));49 }50 [Test]51 public void Execute_Args_ParametersAssigned()52 {53 var resolver = new ExternalFileQueryResolver(BuildArgs());54 var query = resolver.Execute();55 Assert.That(query.Parameters, Has.Count.EqualTo(1));56 }57 [Test]58 public void Execute_InvalidPath_ThrowExternalDependency()59 {60 var args = new ExternalFileQueryResolverArgs(61 @"NotExistingFile.sql",62 ConnectionStringReader.GetSqlClient(),63 new List<IQueryParameter>() { new QueryParameter("param", "10") },64 new List<IQueryTemplateVariable>() { new QueryTemplateVariableXml() { Name = "operator", Value = "not in" } },65 new TimeSpan(0, 0, 10));66 var resolver = new ExternalFileQueryResolver(args);67 Assert.Throws<ExternalDependencyNotFoundException>(() => resolver.Execute());68 }69 [Test]70 public void Execute_InvalidPath_MessageRelativePath()71 {72 var args = new ExternalFileQueryResolverArgs(73 @"NotExistingFile.sql",74 ConnectionStringReader.GetSqlClient(),75 new List<IQueryParameter>() { new QueryParameter("param", "10") },76 new List<IQueryTemplateVariable>() { new QueryTemplateVariableXml() { Name = "operator", Value = "not in" } },77 new TimeSpan(0, 0, 10));78 var resolver = new ExternalFileQueryResolver(args);79 var ex = Assert.Catch<ExternalDependencyNotFoundException>(() => resolver.Execute());80 Assert.That(ex.Message, Does.Contain(@"NBi.Testing\bin\"));81 Assert.That(ex.Message, Does.Contain(@"NotExistingFile.sql"));82 }83 [Test]84 public void Execute_InvalidAbsolutePath_MessageAbsolutePath()85 {86 var args = new ExternalFileQueryResolverArgs(87 @"C:\NotExistingFile.sql",88 ConnectionStringReader.GetSqlClient(),89 new List<IQueryParameter>() { new QueryParameter("param", "10") },90 new List<IQueryTemplateVariable>() { new QueryTemplateVariableXml() { Name = "operator", Value = "not in" } },91 new TimeSpan(0, 0, 10));92 var resolver = new ExternalFileQueryResolver(args);93 var ex = Assert.Catch<ExternalDependencyNotFoundException>(() => resolver.Execute());94 Assert.That(ex.Message, Does.Contain(@"C:\NotExistingFile.sql"));95 }96 }97}...
QueryResolverFactory.cs
Source:QueryResolverFactory.cs
...16 public virtual IQueryResolver Instantiate(BaseQueryResolverArgs args)17 {18 if (args is AssemblyQueryResolverArgs)19 return new AssemblyQueryResolver((AssemblyQueryResolverArgs)args);20 else if (args is ExternalFileQueryResolverArgs)21 return new ExternalFileQueryResolver((ExternalFileQueryResolverArgs)args);22 else if (args is EmbeddedQueryResolverArgs)23 return new EmbeddedQueryResolver((EmbeddedQueryResolverArgs)args);24 else if (args is ReportDataSetQueryResolverArgs)25 return new ReportDataSetQueryResolver((ReportDataSetQueryResolverArgs)args);26 else if (args is SharedDataSetQueryResolverArgs)27 return new SharedDataSetQueryResolver((SharedDataSetQueryResolverArgs)args);28 else if (args is QueryResolverArgs)29 return new QueryResolver((QueryResolverArgs)args);30 throw new ArgumentException();31 }32 }33}...
ExternalFileQueryResolver.cs
Source:ExternalFileQueryResolver.cs
...8using NBi.Extensibility.Query;9using NBi.Extensibility;10namespace NBi.Core.Query.Resolver11{12 class ExternalFileQueryResolver : IQueryResolver13 {14 private readonly ExternalFileQueryResolverArgs args;15 16 public ExternalFileQueryResolver(ExternalFileQueryResolverArgs args)17 {18 this.args = args;19 }20 public IQuery Execute()21 {22 if (!System.IO.File.Exists(args.Path))23 throw new ExternalDependencyNotFoundException(args.Path);24 var commandText = System.IO.File.ReadAllText(args.Path, Encoding.UTF8);25 var query = new Query(commandText, args.ConnectionString, args.Timeout, args.Parameters, args.Variables);26 return query;27 }28 }29}...
ExternalFileQueryResolver
Using AI Code Generation
1using System;2using System.Collections.Generic;3using System.Linq;4using System.Text;5using System.Threading.Tasks;6using NBi.Core.Query.Resolver;7using NBi.Core.Query;8using NBi.Core.Query.Execution;9using NBi.Core.Query.Resolver;10using NBi.Core.Query.Resolver.File;11{12 {13 static void Main(string[] args)14 {15 var fileQueryResolver = new FileQueryResolver();16 fileQueryResolver.Setup(new FileQueryResolverArgs(@"D:\test\test.txt", @"D:\test\test.txt"));17 var query = fileQueryResolver.Execute();18 Console.WriteLine(query);19 Console.ReadLine();20 }21 }22}
ExternalFileQueryResolver
Using AI Code Generation
1using NBi.Core.Query.Resolver;2using System;3using System.Collections.Generic;4using System.Linq;5using System.Text;6using System.Threading.Tasks;7using NBi.Core.Query;8using NBi.Core;9using NBi.Core.ResultSet;10using NBi.Core.ResultSet.Resolver;11using NBi.Core.Scalar.Resolver;12using NBi.Core.Query.Resolver;13using NBi.Core.Query.Client;14using System.Data;15using System.Data.SqlClient;16using System.Configuration;17using NBi.Core.Query.Command;18using NBi.Core.Query.Resolver.File;19using NBi.Core.Query.Resolver.File.Excel;20using NBi.Core.Query.Resolver.File.Csv;21using NBi.Core.Query.Resolver.File.Json;22using NBi.Core.Query.Resolver.File.Xml;23using NBi.Core.Query.Resolver.File.Tsv;24using NBi.Core.Query.Resolver.File.Flat;25using NBi.Core.Query.Resolver.File.Flat.Binary;26using NBi.Core.Query.Resolver.File.Flat.Delimited;27using NBi.Core.Query.Resolver.File.Flat.FixedLength;28using NBi.Core.Query.Resolver.File.Flat.Xml;29using NBi.Core.Query.Resolver.File.Flat.Json;30using NBi.Core.Query.Resolver.File.Flat.Tsv;31using NBi.Core.Query.Resolver.File.Csv;32using NBi.Core.Query.Resolver.File.Json;33using NBi.Core.Query.Resolver.File.Xml;34using NBi.Core.Query.Resolver.File.Tsv;35using NBi.Core.Query.Resolver.File.Flat;36using NBi.Core.Query.Resolver.File.Flat.Binary;37using NBi.Core.Query.Resolver.File.Flat.Delimited;38using NBi.Core.Query.Resolver.File.Flat.FixedLength;39using NBi.Core.Query.Resolver.File.Flat.Xml;40using NBi.Core.Query.Resolver.File.Flat.Json;41using NBi.Core.Query.Resolver.File.Flat.Tsv;42{43 {44 static void Main(string[] args)45 {46 var resolver = new ExternalFileQueryResolver();47 resolver.Setup(new ExternalFileQueryResolverArgs(@"C:\Users\mohit.garg\Documents\NBiTest\NBiTest\bin\Debug\1.xlsx", "select * from [Sheet1$]"));48 var result = resolver.Execute();49 foreach (DataRow row in result.Rows)50 {51 foreach (DataColumn col in result.Columns)52 {53 Console.WriteLine(row[col]);54 }55 }56 }57 }58}
ExternalFileQueryResolver
Using AI Code Generation
1var resolver = new ExternalFileQueryResolver();2resolver.Setup("C:\\Users\\user\\Documents\\Test\\NBi\\NBi.Testing\\NBi.Testing.Integration\\Resources\\Query\\Query.sql");3var query = resolver.Execute();4Console.WriteLine(query);5var resolver = new ExternalFileQueryResolver();6resolver.Setup("C:\\Users\\user\\Documents\\Test\\NBi\\NBi.Testing\\NBi.Testing.Integration\\Resources\\Query\\Query.txt");7var query = resolver.Execute();8Console.WriteLine(query);9var resolver = new ExternalFileQueryResolver();10resolver.Setup("C:\\Users\\user\\Documents\\Test\\NBi\\NBi.Testing\\NBi.Testing.Integration\\Resources\\Query\\Query.xml");11var query = resolver.Execute();12Console.WriteLine(query);13var resolver = new ExternalFileQueryResolver();14resolver.Setup("C:\\Users\\user\\Documents\\Test\\NBi\\NBi.Testing\\NBi.Testing.Integration\\Resources\\Query\\Query.txt");15var query = resolver.Execute();16Console.WriteLine(query);17var resolver = new ExternalFileQueryResolver();18resolver.Setup("C:\\Users\\user\\Documents\\Test\\NBi\\NBi.Testing\\NBi.Testing.Integration\\Resources\\Query\\Query.sql");19var query = resolver.Execute();20Console.WriteLine(query);21var resolver = new ExternalFileQueryResolver();22resolver.Setup("C:\\Users\\user\\Documents\\Test\\NBi\\NBi.Testing\\NBi.Testing.Integration\\Resources\\Query\\Query.xml");23var query = resolver.Execute();24Console.WriteLine(query);
ExternalFileQueryResolver
Using AI Code Generation
1using System;2using System.Collections.Generic;3using System.Linq;4using System.Text;5using System.Threading.Tasks;6using System.Data;7using System.Data.SqlClient;8using NBi.Core.Query;9using NBi.Core.Query.Client;10using NBi.Core.Query.Resolver;11using NBi.Core.ResultSet;12using NBi.Core.ResultSet.Comparer;13using NBi.Core.ResultSet.Resolver;14using NBi.Core.ResultSet.Report;15using NBi.Core.Transformation;16using NBi.Core.Transformation.Transformer;17using System.IO;18{19 {20 static void Main(string[] args)21 {22 string connectionString = @"Data Source=.\SQL2014;Initial Catalog=AdventureWorks2014;Integrated Security=True";23 string queryFile = @"C:\Users\Public\Documents\NBi\Queries\MyQuery.sql";24 string reportFile = @"C:\Users\Public\Documents\NBi\Reports\MyReport.txt";25 var queryResolver = new ExternalFileQueryResolver(queryFile);26 var queryClient = new SqlClientClient(connectionString);27 var resultSetResolver = new ResultSetResolver(queryResolver, queryClient);28 var resultSetComparer = new ResultSetComparer();29 var resultSetReport = new ResultSetReport();30 var resultSetReportWriter = new ResultSetReportTextWriter(reportFile);31 var resultSet = resultSetResolver.Execute();32 var result = resultSetComparer.Compare(resultSet);33 var report = resultSetReport.Report(result);34 resultSetReportWriter.Write(report);35 Console.ReadLine();36 }37 }38}
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!!