How to use ServiceLocator method of NBi.Testing.Core.Query.Execution.ExecutionEngineFactoryTest class

Best NBi code snippet using NBi.Testing.Core.Query.Execution.ExecutionEngineFactoryTest.ServiceLocator

ExecutionEngineFactoryTest.cs

Source:ExecutionEngineFactoryTest.cs Github

copy

Full Screen

...16namespace NBi.Testing.Core.Query.Execution17{18 public class ExecutionEngineFactoryTest19 {20 private readonly ServiceLocator serviceLocator = new ServiceLocator();21 [Test]22 public void Instantiate_SqlClient_SqlExecutionEngine()23 {24 var query = Mock.Of<IQuery>(25 x => x.ConnectionString == ConnectionStringReader.GetSqlClient()26 && x.Statement == "select 1"27 );28 var factory = serviceLocator.GetExecutionEngineFactory();29 var engine = factory.Instantiate(query);30 Assert.IsInstanceOf<SqlExecutionEngine>(engine);31 }32 [Test]33 public void Instantiate_Adomd_AdomdExecutionEngine()34 {35 var query = Mock.Of<IQuery>(36 x => x.ConnectionString == ConnectionStringReader.GetAdomd()37 && x.Statement == "select 1 on 0"38 );39 var factory = serviceLocator.GetExecutionEngineFactory();40 var engine = factory.Instantiate(query);41 Assert.IsInstanceOf<AdomdExecutionEngine>(engine);42 }43 [Test]44 public void Instantiate_Odbc_OdbcExecutionEngine()45 {46 var query = Mock.Of<IQuery>(47 x => x.ConnectionString == ConnectionStringReader.GetOdbcSql()48 && x.Statement == "select 1"49 );50 var factory = serviceLocator.GetExecutionEngineFactory();51 var engine = factory.Instantiate(query);52 Assert.IsInstanceOf<OdbcExecutionEngine>(engine);53 }54 [Test]55 public void Instantiate_OleDb_OleDbExecutionEngine()56 {57 var query = Mock.Of<IQuery>(58 x => x.ConnectionString == ConnectionStringReader.GetOleDbSql()59 && x.Statement == "select 1"60 );61 var factory = serviceLocator.GetExecutionEngineFactory();62 var engine = factory.Instantiate(query);63 Assert.IsInstanceOf<OleDbExecutionEngine>(engine);64 }65 #region Fake66 public class FakeSession : IClient67 {68 public string ConnectionString => "fake://MyConnectionString";69 public Type UnderlyingSessionType => typeof(object);70 public object CreateNew() => throw new NotImplementedException();71 }72 public class FakeSessionFactory : IClientFactory73 {74 public bool CanHandle(string connectionString) => connectionString.StartsWith("fake://");75 public IClient Instantiate(string connectionString) => new FakeSession();76 }77 public class FakeCommand : ICommand78 {79 public object Implementation => new FakeImplementationCommand();80 public object Client => new FakeSession();81 public object CreateNew() => throw new NotImplementedException();82 }83 public class FakeImplementationCommand84 { }85 public class FakeCommandFactory : ICommandFactory86 {87 public bool CanHandle(IClient session) => session is FakeSession;88 public ICommand Instantiate(IClient session, IQuery query, ITemplateEngine engine) => new FakeCommand();89 }90 [SupportedCommandType(typeof(FakeImplementationCommand))]91 private class FakeExecutionEngine : IExecutionEngine92 {93 public FakeExecutionEngine(FakeSession session, object command)94 { }95 public DataSet Execute() => throw new NotImplementedException();96 public IEnumerable<T> ExecuteList<T>() => throw new NotImplementedException();97 public object ExecuteScalar() => throw new NotImplementedException();98 }99 #endregion100 [Test]101 public void Instantiate_FakeConnectionString_FakeExecutionEngine()102 {103 var localServiceLocator = new ServiceLocator();104 var query = Mock.Of<IQuery>(x => x.ConnectionString == "fake://MyConnectionString");105 var sessionFactory = localServiceLocator.GetSessionFactory();106 sessionFactory.RegisterFactories(new[] { typeof(FakeSessionFactory) });107 var commandFactory = localServiceLocator.GetCommandFactory();108 commandFactory.RegisterFactories(new[] { typeof(FakeCommandFactory) });109 var factory = new ExecutionEngineFactory(sessionFactory, commandFactory);110 factory.RegisterEngines(new[] { typeof(FakeExecutionEngine) });111 var engine = factory.Instantiate(query);112 Assert.IsInstanceOf<FakeExecutionEngine>(engine);113 }114 [Test]115 public void Instantiate_FakeConnectionStringExtensions_FakeExecutionEngine()116 {117 var localServiceLocator = new ServiceLocator();118 var setupConfig = localServiceLocator.GetConfiguration();119 var extensions = new Dictionary<Type, IDictionary<string, string>>120 {121 { typeof(FakeSessionFactory), new Dictionary<string, string>() },122 { typeof(FakeCommandFactory), new Dictionary<string, string>() },123 { typeof(FakeExecutionEngine), new Dictionary<string, string>() },124 };125 setupConfig.LoadExtensions(extensions);126 var query = Mock.Of<IQuery>(x => x.ConnectionString == "fake://MyConnectionString");127 var factory = localServiceLocator.GetExecutionEngineFactory();128 var engine = factory.Instantiate(query);129 Assert.IsInstanceOf<FakeExecutionEngine>(engine);130 }131 }132}...

Full Screen

Full Screen

ServiceLocator

Using AI Code Generation

copy

Full Screen

1using NBi.Testing.Core.Query.Execution;2using NUnit.Framework;3using System;4using System.Collections.Generic;5using System.Linq;6using System.Text;7using System.Threading.Tasks;8{9 {10 public void Create_WithServiceLocator_ReturnExecutionEngine()11 {12 var factory = new ExecutionEngineFactory();13 var engine = factory.Create("ServiceLocator");14 Assert.That(engine, Is.Not.Null);15 }16 }17}18using NBi.Testing.Core.Query.Execution;19using NUnit.Framework;20using System;21using System.Collections.Generic;22using System.Linq;23using System.Text;24using System.Threading.Tasks;25{26 {27 public void Create_WithServiceLocator_ReturnExecutionEngine()28 {29 var factory = new ExecutionEngineFactory();30 var engine = factory.Create("ServiceLocator");31 Assert.That(engine, Is.Not.Null);32 }33 }34}35using NBi.Testing.Core.Query.Execution;36using NUnit.Framework;37using System;38using System.Collections.Generic;39using System.Linq;40using System.Text;41using System.Threading.Tasks;42{43 {44 public void Create_WithServiceLocator_ReturnExecutionEngine()45 {46 var factory = new ExecutionEngineFactory();47 var engine = factory.Create("ServiceLocator");48 Assert.That(engine, Is.Not.Null);49 }50 }51}52using NBi.Testing.Core.Query.Execution;53using NUnit.Framework;54using System;55using System.Collections.Generic;56using System.Linq;57using System.Text;58using System.Threading.Tasks;59{60 {61 public void Create_WithServiceLocator_ReturnExecutionEngine()62 {63 var factory = new ExecutionEngineFactory();

Full Screen

Full Screen

ServiceLocator

Using AI Code Generation

copy

Full Screen

1using NBi.Testing.Core.Query.Execution;2using NUnit.Framework;3using System;4using System.Collections.Generic;5using System.Linq;6using System.Text;7using System.Threading.Tasks;8{9 {10 public void GetExecutionEngine_WithMySqlEngine_ReturnMySqlEngine()11 {12 var factory = new ExecutionEngineFactory();13 var engine = factory.GetExecutionEngine("MySql");14 Assert.That(engine, Is.TypeOf<Execution.MySql.MySqlEngine>());15 }16 }17}18using NBi.Testing.Core.Query.Execution;19using NUnit.Framework;20using System;21using System.Collections.Generic;22using System.Linq;23using System.Text;24using System.Threading.Tasks;25{26 {27 public void GetExecutionEngine_WithMySqlEngine_ReturnMySqlEngine()28 {29 var factory = new ExecutionEngineFactory();30 var engine = factory.GetExecutionEngine("MySql");31 Assert.That(engine, Is.TypeOf<Execution.MySql.MySqlEngine>());32 }33 }34}35using NBi.Testing.Core.Query.Execution;36using NUnit.Framework;37using System;38using System.Collections.Generic;39using System.Linq;40using System.Text;41using System.Threading.Tasks;42{43 {44 public void GetExecutionEngine_WithMySqlEngine_ReturnMySqlEngine()45 {46 var factory = new ExecutionEngineFactory();47 var engine = factory.GetExecutionEngine("MySql");48 Assert.That(engine, Is.TypeOf<Execution.MySql.MySqlEngine>());49 }50 }51}52using NBi.Testing.Core.Query.Execution;53using NUnit.Framework;54using System;55using System.Collections.Generic;56using System.Linq;57using System.Text;58using System.Threading.Tasks;59{

Full Screen

Full Screen

ServiceLocator

Using AI Code Generation

copy

Full Screen

1using System;2using System.Collections.Generic;3using System.Linq;4using System.Text;5using System.Threading.Tasks;6using NUnit.Framework;7using NBi.Core.Query;8using NBi.Core.Query.Execution;9using NBi.Core.Query.Resolver;10using NBi.Core.Query.Resolver.Csv;11using NBi.Core.Query.Resolver.Variables;12using Moq;13using NBi.Core.Injection;14using NBi.Core.Query.Client;15using NBi.Core;16using NBi.Core.Query.Command;17using NBi.Core.Query.Command.Csv;18using NBi.Core.Query.Execution.Csv;19{20 {21 public void Instantiate_CsvFile_ReturnCsvEngine()22 {23 var resolver = new CsvFileQueryResolver(new CsvFileQueryResolverArgs("Test.csv"));24 var engine = ExecutionEngineFactory.Instantiate(resolver);25 Assert.That(engine, Is.InstanceOf<CsvEngine>());26 }27 }28}29using System;30using System.Collections.Generic;31using System.Linq;32using System.Text;33using System.Threading.Tasks;34using NUnit.Framework;35using NBi.Core.Query;36using NBi.Core.Query.Execution;37using NBi.Core.Query.Resolver;38using NBi.Core.Query.Resolver.Csv;39using NBi.Core.Query.Resolver.Variables;40using Moq;41using NBi.Core.Injection;42using NBi.Core.Query.Client;43using NBi.Core;44using NBi.Core.Query.Command;45using NBi.Core.Query.Command.Csv;46using NBi.Core.Query.Execution.Csv;47{48 {49 public void Instantiate_CsvFile_ReturnCsvEngine()50 {51 var resolver = new CsvFileQueryResolver(new CsvFileQueryResolverArgs("Test.csv"));52 var engine = ExecutionEngineFactory.Instantiate(resolver);53 Assert.That(engine, Is.InstanceOf<CsvEngine>());54 }55 }56}57using System;58using System.Collections.Generic;59using System.Linq;60using System.Text;61using System.Threading.Tasks;62using NUnit.Framework;63using NBi.Core.Query;

Full Screen

Full Screen

ServiceLocator

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.Query.Execution;7using NBi.Core.Query;8using NBi.Core.Query.Resolver;9using NBi.Core.Query.Command;10using NBi.Core.Query.Client;11using NBi.Core.Query.Client.SqlClient;12using NBi.Core.Query.Client.Odbc;13using NBi.Core.Query.Client.Oracle;14using NBi.Core.Query.Client.OleDb;15using NBi.Core.Query.Client.MySql;16using NBi.Core.Query.Client.Presto;17using NBi.Core.Query.Client.SqLite;18using NBi.Core.Query.Client.SqLite.Native;19using NBi.Core.Query.Client.Php;20using NBi.Core.Query.Client.Php.Pdo;21using NBi.Core.Query.Client.Php.Pdo.Sqlite;22using NBi.Core.Query.Client.Php.Pdo.Pgsql;23using NBi.Core.Query.Client.Php.Pdo.Odbc;24using NBi.Core.Query.Client.Php.Pdo.Oci;25using NBi.Core.Query.Client.Php.Pdo.Mysql;26using NBi.Core.Query.Client.Php.Pdo.Sqlsrv;27using NBi.Core.Query.Client.Php.Pdo.Pdo;28using NBi.Core.Query.Client.Php.Pdo.Pdo.Mysql;29using NBi.Core.Query.Client.Php.Pdo.Pdo.Oci;30using NBi.Core.Query.Client.Php.Pdo.Pdo.Odbc;31using NBi.Core.Query.Client.Php.Pdo.Pdo.Sqlsrv;32using NBi.Core.Query.Client.Php.Pdo.Pdo.Sqlite;33using NBi.Core.Query.Client.Php.Pdo.Pdo.Pgsql;34using NBi.Core.Query.Client.Php.Pdo.Pgsql;35using NBi.Core.Query.Client.Php.Pdo.Sqlsrv;36using NBi.Core.Query.Client.Php.Pdo.Sqlsrv;37using NBi.Core.Query.Client.Php.Pdo.Oci;38using NBi.Core.Query.Client.Php.Pdo.Oci;39using NBi.Core.Query.Client.Php.Pdo.Mysql;40using NBi.Core.Query.Client.Php.Pdo.Mysql;41using NBi.Core.Query.Client.Php.Pdo.Sqlite;42using NBi.Core.Query.Client.Php.Pdo.Sqlite;43using NBi.Core.Query.Client.Php.Pdo.Pgsql;44using NBi.Core.Query.Client.Php.Pdo.Pgsql;45using NBi.Core.Query.Client.Php.Pdo.Odbc;

Full Screen

Full Screen

ServiceLocator

Using AI Code Generation

copy

Full Screen

1using NBi.Testing.Core.Query.Execution;2using NBi.Core.Query.Execution;3using NUnit.Framework;4using System;5using System.Collections.Generic;6using System.Linq;7using System.Text;8using System.Threading.Tasks;9using System.Data;10using Moq;11using NBi.Core.Query;12using System.Data.Common;13using NBi.Core.Query.Resolver;14using NBi.Core.Query.Command;15using NBi.Core.Query.Client;16using NBi.Core.Query.Client.SqlClient;17using NBi.Core.Query.Client.ODBC;18using NBi.Core.Query.Client.OleDb;19using NBi.Core.Query.Client.Oracle;20using NBi.Core.Query.Client.MySql;21using NBi.Core.Query.Client.PostgreSql;22using NBi.Core.Query.Client.SQLite;23using NBi.Core.Query.Client.Access;24using NBi.Core.Query.Client.SqLite;25{26 {27 public void Instantiate_SqlClient_Ok()28 {29 var command = Mock.Of<ICommand>();30 var resolver = Mock.Of<IConnectionStringResolver>();31 var factory = new ExecutionEngineFactory(resolver);32 var engine = factory.Instantiate(command);33 Assert.That(engine, Is.InstanceOf<SqlClientExecutionEngine>());34 }35 public void Instantiate_Odbc_Ok()36 {37 var command = Mock.Of<ICommand>();38 var resolver = Mock.Of<IConnectionStringResolver>(c => c.GetConnectionString() == "Driver={SQL Server};");39 var factory = new ExecutionEngineFactory(resolver);40 var engine = factory.Instantiate(command);41 Assert.That(engine, Is.InstanceOf<OdbcExecutionEngine>());42 }43 public void Instantiate_OleDb_Ok()44 {45 var command = Mock.Of<ICommand>();46 var resolver = Mock.Of<IConnectionStringResolver>(c => c.GetConnectionString() == "Provider=SQLNCLI11;");47 var factory = new ExecutionEngineFactory(resolver);48 var engine = factory.Instantiate(command);49 Assert.That(engine, Is.InstanceOf<OleDbExecutionEngine>());50 }51 public void Instantiate_Oracle_Ok()52 {53 var command = Mock.Of<ICommand>();54 var resolver = Mock.Of<IConnectionStringResolver>(c => c.GetConnectionString() == "Provider=MSDAORA;");55 var factory = new ExecutionEngineFactory(resolver);56 var engine = factory.Instantiate(command);57 Assert.That(engine,

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.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful