public static TestTdsServer StartServerWithQueryEngine(QueryEngine engine, int port = 0, int timeout = 600, bool enableFedAuth = false, bool enableLog = false, [CallerMemberName] string methodName = "") { TDSServerArguments args = new TDSServerArguments() { Log = enableLog ? Console.Out : null, }; if (enableFedAuth) { args.FedAuthRequiredPreLoginOption = Microsoft.SqlServer.TDS.PreLogin.TdsPreLoginFedAuthRequiredOption.FedAuthRequired; } TestTdsServer server = engine == null ? new TestTdsServer(args) : new TestTdsServer(engine, args); server._endpoint = new TDSServerEndPoint(server) { ServerEndPoint = new IPEndPoint(IPAddress.Any, port) }; server._endpoint.EndpointName = methodName; // The server EventLog should be enabled as it logs the exceptions. server._endpoint.EventLog = enableLog ? Console.Out : TextWriter.Null; server._endpoint.Start(); server.connectionStringBuilder = new SqlConnectionStringBuilder() { DataSource = "localhost," + port, ConnectTimeout = timeout, Encrypt = false }; server.ConnectionString = server.connectionStringBuilder.ConnectionString; return(server); }
public override void Stop() { if (null != _server) { _server.Dispose(); _server = null; } }
public override Task StartInternalAsync() { var arguments = new TDSServerArguments { Log = Console.Out }; _engine = new StaticQueryEngine(arguments); foreach (var stub in _exestingStubs) { _engine.AddStub(stub); } _engine.Name = Settings.Name; _server = TestTdsServer.StartTestServer(_engine, port: Settings.Port, enableLog: false); return(Task.Run(() => WaitHandle.WaitAll(new WaitHandle[] { Token.WaitHandle }))); }