예제 #1
0
        public void TestParseLineWithOpenColumnAndLeadingTab()
        {
            var daxLine = DaxLineParser.ParseLine("\ttable[column", 12, 0);

            Assert.AreEqual(LineState.Column, daxLine.LineState);
            Assert.AreEqual("table", daxLine.TableName);
        }
예제 #2
0
        public void TestParseLineWithOpenColumnAndPreceedingString()
        {
            var testText = "\"table[column\" 'table";

            Assert.AreEqual(LineState.Table, DaxLineParser.ParseLine(testText, testText.Length - 1, 0).LineState, "Table state not detected");
            Assert.AreEqual(LineState.String, DaxLineParser.ParseLine(testText, 10, 0).LineState, "string state not detected");
        }
예제 #3
0
        public void GetCompletionSegmentTestWithLeadingAndTrailingText()
        {
            //                   0123456789012345678901234567890123456789
            //         01234567891111111111222222222233333333334444444444
            var dax = "filter( table[column] , table[column]=\"red\"";
            //                       ^ 15                       ^ 41
            var daxState = DaxLineParser.ParseLine(dax, 15, 0);

            Assert.AreEqual(LineState.Column, daxState.LineState);
            Assert.AreEqual(13, daxState.StartOffset, "StartOffset");
            Assert.AreEqual(21, daxState.EndOffset, "EndOffset");
            Assert.AreEqual("table", daxState.TableName);

            var daxState2 = DaxLineParser.ParseLine(dax, 41, 0);

            Assert.AreEqual(LineState.String, daxState2.LineState);
            Assert.AreEqual(38, daxState2.StartOffset, "StartOffset String");
            Assert.AreEqual(42, daxState2.EndOffset, "EndOffset String");

            var daxState3 = DaxLineParser.ParseLine(dax, 3, 0);

            Assert.AreEqual(LineState.LetterOrDigit, daxState3.LineState);
            Assert.AreEqual(0, daxState3.StartOffset, "StartOffset Filter");
            Assert.AreEqual(6, daxState3.EndOffset, "EndOffset Filter");
        }
예제 #4
0
        public void SimpleDmvParsing()
        {
            var dax      = "$SYSTEM.dis";
            var daxState = DaxLineParser.ParseLine(dax, 11, 0);

            Assert.AreEqual(LineState.Dmv, daxState.LineState);
            Assert.AreEqual(8, daxState.StartOffset, "StartOffset");
        }
예제 #5
0
        public void DmvParsing()
        {
            var dax      = "SELECT * FROM $SYSTEM.dis";
            var daxState = DaxLineParser.ParseLine(dax, 24, 0);

            Assert.AreEqual(LineState.Dmv, daxState.LineState);
            Assert.AreEqual(22, daxState.StartOffset, "StartOffset");
        }
예제 #6
0
        public void MultiLineParsing()
        {
            var daxState = DaxLineParser.ParseLine(" e", 2, 6);

            Assert.AreEqual(LineState.LetterOrDigit, daxState.LineState);
            Assert.AreEqual(7, daxState.StartOffset, "StartOffset");
            Assert.AreEqual(8, daxState.EndOffset, "EndOffset");
        }
예제 #7
0
        public void GetCompletionSegmentTest()
        {
            var daxState = DaxLineParser.ParseLine("table[column]", 10, 0);

            Assert.AreEqual(LineState.Column, daxState.LineState);
            Assert.AreEqual("column", daxState.ColumnName);
            Assert.AreEqual(5, daxState.StartOffset, "StartOffset");
            Assert.AreEqual(13, daxState.EndOffset, "EndOffset");
        }
예제 #8
0
        public void TestMidStatementParsing()
        {
            var qry      = "EVALUATE FILTER(Reseller, Reseller[Reselle]= \"bob\")";
            var daxState = DaxLineParser.ParseLine(qry, 42, 0);

            Assert.AreEqual(LineState.Column, daxState.LineState, "LineState");
            Assert.AreEqual(43, daxState.EndOffset, "EndOffset");
            Assert.AreEqual(34, daxState.StartOffset, "StartOffset");
        }
예제 #9
0
        public void TestParseOpenColumnWithTrailingSpace()
        {
            var testText = "EVALUE FILTER('Products', 'product'[Product ";
            var daxState = DaxLineParser.ParseLine(testText, testText.Length - 1, 0);

            Assert.AreEqual(LineState.Column, daxState.LineState, "Column state not detected");
            Assert.AreEqual("Product ", daxState.ColumnName, "preceeding word not correct");

            Assert.AreEqual(LineState.Table, DaxLineParser.ParseLine(testText, 30, 0).LineState, "string state not detected");
        }
예제 #10
0
        public void TestFunctionCompletion()
        {
            var line     = "CALCULATE FILVALUES([MyColumn])";
            var col      = 13;
            var daxState = DaxLineParser.ParseLine(line, col, 0);

            var pos = DaxLineParser.GetPreceedingWordSegment(0, col, line, daxState);

            System.Diagnostics.Debug.WriteLine(pos);
            Assert.AreEqual(3, pos.Length);
        }
예제 #11
0
        public void TestParsingToFindFunctionWithPeriod()
        {
            var qry = "EVALUATE EXPON.DIST(123";
            //                    ^
            var daxState = DaxLineParser.ParseLine(qry, 11, 0);

            Assert.AreEqual(LineState.LetterOrDigit, daxState.LineState, "LineState");
            Assert.AreEqual(19, daxState.EndOffset, "EndOffset");
            Assert.AreEqual(9, daxState.StartOffset, "StartOffset");
            Assert.AreEqual("EXPON.DIST", qry.Substring(daxState.StartOffset, daxState.EndOffset - daxState.StartOffset));
        }
예제 #12
0
        public void GetCompletionSegmentTestWithTabBeforeTableName()
        {
            var dax = "\t'table";
            //               ^ 5
            var daxState = DaxLineParser.ParseLine(dax, dax.Length - 1, 0);

            Assert.AreEqual(LineState.Table, daxState.LineState);
            Assert.AreEqual(1, daxState.StartOffset, "StartOffset");
            Assert.AreEqual(dax.Length - 1, daxState.EndOffset, "EndOffset");
            Assert.AreEqual("table", daxState.TableName);
        }
예제 #13
0
        public void GetCompletionSegmentTestWithQuotedTableName()
        {
            var dax = "evaluate filter('my table', 'my table'[column name";
            //                                                ^ 39
            var daxState = DaxLineParser.ParseLine(dax, dax.Length - 1, 0);

            Assert.AreEqual(LineState.Column, daxState.LineState);
            Assert.AreEqual(38, daxState.StartOffset, "StartOffset");
            Assert.AreEqual(dax.Length - 1, daxState.EndOffset, "EndOffset");
            Assert.AreEqual("my table", daxState.TableName);
        }
예제 #14
0
        public void TestParsingToFindFunction()
        {
            var qry = "EVALUATE FILTER(Reseller, Reseller[Reselle]= \"bob\")";
            //                    ^
            var daxState = DaxLineParser.ParseLine(qry, 11, 0);

            Assert.AreEqual(LineState.LetterOrDigit, daxState.LineState, "LineState");
            Assert.AreEqual(15, daxState.EndOffset, "EndOffset");
            Assert.AreEqual(9, daxState.StartOffset, "StartOffset");
            Assert.AreEqual("FILTER", qry.Substring(daxState.StartOffset, daxState.EndOffset - daxState.StartOffset));
        }
예제 #15
0
        public void TestParseOpenTable()
        {
            //                        0
            //              01234567891
            var testText = "FILTER('Pr";
            var daxState = DaxLineParser.ParseLine(testText, testText.Length, 0);

            Assert.AreEqual(LineState.Table, daxState.LineState, "Table state not detected");
            //Assert.AreEqual(7, daxState.StartOffset);
            Assert.AreEqual(10, daxState.EndOffset);
        }
        public void TestDmvCompletion()
        {
            var line     = "SELECT * FROM $SYS";
            var col      = line.Length;
            var daxState = DaxLineParser.ParseLine(line, col, 0);

            var pos = DaxLineParser.GetPreceedingWordSegment(0, col, line, daxState);

            System.Diagnostics.Debug.WriteLine(pos);
            Assert.AreEqual(14, pos.Offset);
            Assert.AreEqual(4, pos.Length);
        }
예제 #17
0
        public void GetCompletionSegmentTestWithUnderscoreTableName()
        {
            var dax = "filter(Dim_D";
            //                                         ^ 32
            var daxState = DaxLineParser.ParseLine(dax, dax.Length - 1, 0);

            Assert.AreEqual(LineState.LetterOrDigit, daxState.LineState);
            Assert.AreEqual(dax.Length - 1, daxState.EndOffset, "EndOffset");
            Assert.AreEqual(dax.Length - "Dim_D".Length, daxState.StartOffset, "StartOffset");

            //Assert.AreEqual("my table", daxState.TableName);
        }
예제 #18
0
        public void TestParsingToFindFunctionWithoutTrailingSpace()
        {
            var qry = "EVALUATE";
            //                    ^
            var daxState = DaxLineParser.ParseLine(qry, 1, 0);

            Assert.AreEqual(LineState.LetterOrDigit, daxState.LineState, "LineState");
            Assert.AreEqual(0, daxState.StartOffset, "StartOffset");
            Assert.AreEqual(8, daxState.EndOffset, "EndOffset");

            Assert.AreEqual("EVALUATE", qry.Substring(daxState.StartOffset, daxState.EndOffset - daxState.StartOffset));
        }
예제 #19
0
        public void GetCompletionSegmentMidColumn()
        {
            //                   01234567890123
            //         012345678911111111112222
            var dax = "'my table'[column name], blah";
            //                         ^16
            var daxState = DaxLineParser.ParseLine(dax, 11, 0);

            Assert.AreEqual(LineState.Column, daxState.LineState);
            Assert.AreEqual(10, daxState.StartOffset, "StartOffset");
            Assert.AreEqual(23, daxState.EndOffset, "EndOffset");
            Assert.AreEqual("my table", daxState.TableName);
        }
        public void TestClosedColumnCompletion()
        {
            var line     = "'Store'[Store K]), @Store = \"All\" )";
            var col      = 15;
            var daxState = DaxLineParser.ParseLine(line, col, 0);

            var pos = DaxLineParser.GetPreceedingWordSegment(0, col, line, daxState);

            System.Diagnostics.Debug.WriteLine(pos);
            var colName = line.Substring(pos.Offset, pos.Length);

            Assert.AreEqual(7, pos.Offset);
            Assert.AreEqual("[Store K]", colName);
            Assert.AreEqual(LineState.ColumnClosed, daxState.LineState);
        }
예제 #21
0
 public void TestFindTableNameUsListSeparator()
 {
     Assert.AreEqual("table1", DaxLineParser.GetPreceedingTableName("filter(table, table1["));
 }
예제 #22
0
 public void TestFindTableNameFunctionNoSpaceAndEvaluate()
 {
     Assert.AreEqual("table", DaxLineParser.GetPreceedingTableName("evaluate filter(table"));
 }
예제 #23
0
 public void TestFindTableNameQuotedFunctionNoSpaceAndOperator()
 {
     Assert.AreEqual("table2", DaxLineParser.GetPreceedingTableName("filter(table, table1[col1]='table2"));
 }
예제 #24
0
 public void TestFindTableNameFunctionWithUnderscores()
 {
     Assert.AreEqual("Dim_D", DaxLineParser.GetPreceedingTableName("filter(Dim_D"));
 }
예제 #25
0
 public void TestFindTableNameSimple()
 {
     Assert.AreEqual("table", DaxLineParser.GetPreceedingTableName("filter( table"));
     Assert.AreEqual("table2", DaxLineParser.GetPreceedingTableName("evaluate filter( table2"));
 }
예제 #26
0
 public void TestParseLineWithOpenTable()
 {
     Assert.AreEqual(LineState.Table, DaxLineParser.ParseLine("'table", 6, 0).LineState);
 }
예제 #27
0
 public void TestParseLineWithOpenColumn()
 {
     Assert.AreEqual(LineState.Column, DaxLineParser.ParseLine("table[column", 12, 0).LineState);
 }
예제 #28
0
 public void TestFindTableNameEuropeanListSeparator()
 {
     Assert.AreEqual("table1", DaxLineParser.GetPreceedingTableName("filter(table;table1[col1"));
 }
예제 #29
0
 public void TestFindFunctionNameWithSpace()
 {
     Assert.AreEqual("filter", DaxLineParser.GetPreceedingWord("evaluate filter "));
 }