コード例 #1
0
        public async Task ConnectOnPremTest()
        {
            TestServerType serverType = TestServerType.OnPrem;

            using (SelfCleaningTempFile queryTempFile = new SelfCleaningTempFile())
                using (TestServiceDriverProvider testService = new TestServiceDriverProvider())
                {
                    const string query = Scripts.TestDbSimpleSelectQuery;
                    testService.WriteToFile(queryTempFile.FilePath, query);

                    DidOpenTextDocumentNotification openParams = new DidOpenTextDocumentNotification
                    {
                        TextDocument = new TextDocumentItem
                        {
                            Uri        = queryTempFile.FilePath,
                            LanguageId = "enu",
                            Version    = 1,
                            Text       = query
                        }
                    };

                    await testService.RequestOpenDocumentNotification(openParams);

                    Thread.Sleep(500);
                    var connected = await testService.CalculateRunTime(async() =>
                    {
                        var connectParams = testService.GetConnectionParameters(serverType, Common.PerfTestDatabaseName);
                        return(await testService.Connect(queryTempFile.FilePath, connectParams));
                    }, true);

                    Assert.True(connected, "Connection was not successful");
                }
        }
コード例 #2
0
ファイル: StressTests.cs プロジェクト: winzig/sqltoolsservice
        /// <summary>
        /// Repeatedly connect and disconnect to stress test the connection service.
        /// </summary>
        //[Fact]
        public async Task TestConnectionService()
        {
            string ownerUri = "file:///my/test/file.sql";


            using (TestServiceDriverProvider testService = new TestServiceDriverProvider())
            {
                var connection = testService.GetConnectionParameters(TestServerType.OnPrem);
                connection.Connection.Pooling = false;

                // Connect/disconnect repeatedly
                Stopwatch stopwatch = new Stopwatch();
                stopwatch.Start();
                while (stopwatch.Elapsed < TimeSpan.FromMinutes(60))
                {
                    // Connect
                    bool connected = await testService.Connect(ownerUri, connection);

                    Assert.True(connected, "Connection is successful");

                    // Disconnect
                    bool disconnected = await testService.Disconnect(ownerUri);

                    Assert.True(disconnected, "Disconnect is successful");
                }
            }
        }