Exemple #1
0
        public int Add(Postgres connection, User user)
        {
            var queryConstructor = new QueryConstructor <User>();
            var sql = queryConstructor.BuildeInsertQuery(user, "public", "user", false);

            return(connection.ExecuteReturnIdIntTransaction(sql, "id"));
        }
Exemple #2
0
        private List <Result> WindowsIndexTopLevelFolderSearch(Query query, string path)
        {
            var queryConstructor = new QueryConstructor(settings);

            return(indexSearch.WindowsIndexSearch(path,
                                                  queryConstructor.CreateQueryHelper().ConnectionString,
                                                  queryConstructor.QueryForTopLevelDirectorySearch,
                                                  query));
        }
Exemple #3
0
        private List <Result> WindowsIndexFilesAndFoldersSearch(Query query, string querySearchString)
        {
            var queryConstructor = new QueryConstructor(settings);

            return(indexSearch.WindowsIndexSearch(querySearchString,
                                                  queryConstructor.CreateQueryHelper().ConnectionString,
                                                  queryConstructor.QueryForAllFilesAndFolders,
                                                  query));
        }
Exemple #4
0
        public void GivenWindowsIndexSearch_WhenSearchTypeIsTopLevelDirectorySearch_ThenQueryShouldUseExpectedString(string folderPath, string expectedString)
        {
            // Given
            var queryConstructor = new QueryConstructor(new Settings());

            //When
            var queryString = queryConstructor.QueryForTopLevelDirectorySearch(folderPath);

            // Then
            Assert.IsTrue(queryString == expectedString,
                          $"Expected string: {expectedString}{Environment.NewLine} " +
                          $"Actual string was: {queryString}{Environment.NewLine}");
        }
Exemple #5
0
        public void GivenWindowsIndexSearch_WhenSearchPatternHotKeyIsSearchAll_ThenQueryWhereRestrictionsShouldUseScopeString(string path, string expectedString)
        {
            // Given
            var queryConstructor = new QueryConstructor(new Settings());

            //When
            var resultString = queryConstructor.QueryWhereRestrictionsForTopLevelDirectoryAllFilesAndFoldersSearch(path);

            // Then
            Assert.IsTrue(resultString == expectedString,
                          $"Expected QueryWhereRestrictions string: {expectedString}{Environment.NewLine} " +
                          $"Actual string was: {resultString}{Environment.NewLine}");
        }
Exemple #6
0
        public void GivenWindowsIndexSearchTopLevelDirectory_WhenSearchingForSpecificItem_ThenQueryWhereRestrictionsShouldUseDirectoryString(
            string userSearchString, string expectedString)
        {
            // Given
            var queryConstructor = new QueryConstructor(new Settings());

            //When
            var queryString = queryConstructor.QueryWhereRestrictionsForTopLevelDirectorySearch(userSearchString);

            // Then
            Assert.IsTrue(queryString == expectedString,
                          $"Expected string: {expectedString}{Environment.NewLine} " +
                          $"Actual string was: {queryString}{Environment.NewLine}");
        }
Exemple #7
0
        public void GivenWindowsIndexSearch_WhenProvidedFolderPath_ThenQueryWhereRestrictionsShouldUseDirectoryString(string path, string expectedString)
        {
            // Given
            var queryConstructor = new QueryConstructor(new Settings());

            // When
            var folderPath = path;
            var result     = queryConstructor.QueryWhereRestrictionsForTopLevelDirectorySearch(folderPath);

            // Then
            Assert.IsTrue(result == expectedString,
                          $"Expected QueryWhereRestrictions string: {expectedString}{Environment.NewLine} " +
                          $"Actual: {result}{Environment.NewLine}");
        }
Exemple #8
0
        public void GivenWindowsIndexSearch_WhenSearchAllFoldersAndFiles_ThenQueryShouldUseExpectedString(
            string userSearchString, string expectedString)
        {
            // Given
            var queryConstructor = new QueryConstructor(new Settings());

            //When
            var resultString = queryConstructor.QueryForAllFilesAndFolders(userSearchString);

            // Then
            Assert.IsTrue(resultString == expectedString,
                          $"Expected query string: {expectedString}{Environment.NewLine} " +
                          $"Actual string was: {resultString}{Environment.NewLine}");
        }
Exemple #9
0
        private List <Result> WindowsIndexFileContentSearch(Query query, string querySearchString)
        {
            var queryConstructor = new QueryConstructor(settings);

            if (string.IsNullOrEmpty(querySearchString))
            {
                return(new List <Result>());
            }

            return(indexSearch.WindowsIndexSearch(querySearchString,
                                                  queryConstructor.CreateQueryHelper().ConnectionString,
                                                  queryConstructor.QueryForFileContentSearch,
                                                  query));
        }
        public void GivenWindowsIndexSearch_WhenQueryWhereRestrictionsIsForFileContentSearch_ThenShouldReturnFreeTextString(
            string querySearchString, string expectedString)
        {
            // Given
            var queryConstructor = new QueryConstructor(new Settings());

            //When
            var resultString = queryConstructor.QueryWhereRestrictionsForFileContentSearch(querySearchString);

            // Then
            Assert.IsTrue(resultString == expectedString,
                          $"Expected QueryWhereRestrictions string: {expectedString}{Environment.NewLine} " +
                          $"Actual string was: {resultString}{Environment.NewLine}");
        }
Exemple #11
0
        public void TestQueryConstructor()
        {
            /* QueryConstructor qc = new QueryConstructor(
             *  "Article",
             *  "Content",
             *  "Excursion",
             *  "File",
             *  "Region",
             *  "Review",
             *  "Sight",
             *  "Timetable",
             *  "User"
             * );
             *
             * var root = qc.GetAttributes("User");
             *
             * root.Children[1].Criterium = "*****@*****.**";
             *
             * var query = qc.Query(Container.UserSet, root).ToArray(); */

            try
            {
                Register("b", "b", "tema", UserStatus.Administrator);
                Register("a", "a", "tema");
                Register("artem", "1234", "tema");
                Register("arixhan", "1234", "jeembo");
                Register("nobu", "1234", "drake");
                Register("max", "1234", "future");
                Register("ilya", "1234", "the weeknd");
                Register("adrax", "1234", "the weeknd");
                Register("shitajimado", "1234", "future");
            }
            catch (Exception e)
            {
            }

            var qc = new QueryConstructor(
                "User",
                typeof(User)
                );

            var node = qc.GetNode("Nickname");

            node.Criterium          = "future";
            node.ComparisonOperator = BooleanOperator.NotEqual;

            var users = qc.Query(Container.UserSet).ToArray();
        }
Exemple #12
0
        private void EntitiesComboBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            var typename = (string)EntitiesComboBox.SelectedItem;

            var type = QueryConstructor.GetThisAssemblyType(
                typename
                );

            mConstructor = new QueryConstructor(typename, type);

            QueryFlowLayout.Controls.Clear();

            int y = 0;

            ConstructQuery(mConstructor.Root, 0, ref y);

            QueryButton.Enabled = true;
        }
Exemple #13
0
        public void GivenWindowsIndexSearch_WhenSearchAllFoldersAndFiles_ThenQueryShouldUseExpectedString(
            string userSearchString, string expectedString)
        {
            // Given
            var queryConstructor = new QueryConstructor(new Settings());
            var baseQuery        = queryConstructor.CreateBaseQuery();

            // system running this test could have different locale than the hard-coded 1033 LCID en-US.
            var queryKeywordLocale = baseQuery.QueryKeywordLocale;

            expectedString = expectedString.Replace("1033", queryKeywordLocale.ToString());



            //When
            var resultString = queryConstructor.QueryForAllFilesAndFolders(userSearchString);

            // Then
            Assert.IsTrue(resultString == expectedString,
                          $"Expected query string: {expectedString}{Environment.NewLine} " +
                          $"Actual string was: {resultString}{Environment.NewLine}");
        }