コード例 #1
0
        public async static Task <string> CreateQueryResult(string question)
        {
            return(await Task.Run(() =>
            {
                var query = SQLQueryBuilder.Build(question);
                var result = new QueryExecutor(ConnectionHelper.ConnectionString).ExecuteQuery(query);

                return result;
            }));
        }
コード例 #2
0
        public void TestMethod7()
        {
            string testQuestion   = "Какие памятники находятся в Адмиралтейском районе";
            string expectedResult = "SELECT MONUMENTS.NAME FROM AREAS join ADDRESSES on AREAS.ID = ADDRESSES.ID_AREA join MONUMENTS on ADDRESSES.ID = MONUMENTS.ID_ADDRESS WHERE AREAS.NAME like '%Адмиралтейский%'";
            string actualResult   = SQLQueryBuilder.Build(testQuestion);

            Assert.AreEqual(expectedResult, actualResult);

            string sqlResult = new QueryExecution.QueryExecutor(ConnectionHelper.ConnectionString).ExecuteQuery(actualResult);

            Assert.IsFalse(sqlResult.Contains("error"));
        }
コード例 #3
0
        public void TestMethod6()
        {
            string testQuestion   = "Какие парки находятся в г Петергоф";
            string expectedResult = "SELECT PARKS.NAME FROM ADDRESSES join PARKS on ADDRESSES.ID = PARKS.ID_ADDRESS WHERE ADDRESSES.STREET like '%Петергоф%'";
            string actualResult   = SQLQueryBuilder.Build(testQuestion);

            Assert.AreEqual(expectedResult, actualResult);

            string sqlResult = new QueryExecution.QueryExecutor(ConnectionHelper.ConnectionString).ExecuteQuery(actualResult);

            Assert.IsFalse(sqlResult.Contains("error"));
        }
コード例 #4
0
        public void TestMethod5()
        {
            string testQuestion   = "Какие музеи находятся на ул Садовая";
            string expectedResult = "SELECT MUSEUMS.NAME FROM ADDRESSES join MUSEUMS on ADDRESSES.ID = MUSEUMS.ID_ADDRESS WHERE ADDRESSES.STREET like '%Садовая%'";
            string actualResult   = SQLQueryBuilder.Build(testQuestion);

            Assert.AreEqual(expectedResult, actualResult);

            string sqlResult = new QueryExecution.QueryExecutor(ConnectionHelper.ConnectionString).ExecuteQuery(actualResult);

            Assert.IsFalse(sqlResult.Contains("error"));
        }
コード例 #5
0
        public void TestMethod4()
        {
            string testQuestion   = "Где находится Английский парк";
            string expectedResult = "SELECT ADDRESSES.STREET, ADDRESSES.HOUSENUMBER, AREAS.NAME FROM AREAS join ADDRESSES on AREAS.ID = ADDRESSES.ID_AREA join PARKS on ADDRESSES.ID = PARKS.ID_ADDRESS WHERE PARKS.NAME like '%Английский%'";
            string actualResult   = SQLQueryBuilder.Build(testQuestion);

            Assert.AreEqual(expectedResult, actualResult);

            string sqlResult = new QueryExecution.QueryExecutor(ConnectionHelper.ConnectionString).ExecuteQuery(actualResult);

            Assert.IsFalse(sqlResult.Contains("error"));
        }
コード例 #6
0
        public void TestMethod3()
        {
            string testQuestion   = "Где находится Вагон-музей";
            string expectedResult = "SELECT ADDRESSES.STREET, ADDRESSES.HOUSENUMBER, AREAS.NAME FROM AREAS join ADDRESSES on AREAS.ID = ADDRESSES.ID_AREA join MUSEUMS on ADDRESSES.ID = MUSEUMS.ID_ADDRESS WHERE MUSEUMS.DESCRIPTION like '%Вагон-музей%'";
            string actualResult   = SQLQueryBuilder.Build(testQuestion);

            Assert.AreEqual(expectedResult, actualResult);

            string sqlResult = new QueryExecution.QueryExecutor(ConnectionHelper.ConnectionString).ExecuteQuery(actualResult);

            Assert.IsFalse(sqlResult.Contains("error"));
        }
コード例 #7
0
        public void TestMethod2()
        {
            string testQuestion   = "В каком районе находится памятник Ленину";
            string expectedResult = "SELECT AREAS.NAME FROM AREAS join ADDRESSES on AREAS.ID = ADDRESSES.ID_AREA join MONUMENTS on ADDRESSES.ID = MONUMENTS.ID_ADDRESS WHERE MONUMENTS.NAME like '%Ленину%'";
            string actualResult   = SQLQueryBuilder.Build(testQuestion);

            Assert.AreEqual(expectedResult, actualResult);

            string sqlResult = new QueryExecution.QueryExecutor(ConnectionHelper.ConnectionString).ExecuteQuery(actualResult);

            Assert.IsFalse(sqlResult.Contains("error"));
        }
コード例 #8
0
ファイル: Form1.cs プロジェクト: AkshevskyDmitry/Translation
 private void button1_Click(object sender, EventArgs e)
 {
     //q.ExecuteQuery(richTextQuest.Text, comboBox1.SelectedItem.ToString());
     richTextBox1.Text = SQLQueryBuilder.Build(richTextQuest.Text);
     richTextBox2.Text = new QueryExecution.QueryExecutor(ConnectionHelper.ConnectionString).ExecuteQuery(richTextBox1.Text);
 }