public async Task TestDaxFormatterProxyWithLongQuery() { var qry = @" EVALUATE CALCULATETABLE( ADDCOLUMNS ( GENERATE ( GENERATE ( VALUES ( 'SalesTerritory'[SalesTerritory Country] ), VALUES ( 'Product'[Colour] ) ), VALUES ( 'Reseller'[BusinessType] ) ), ""Sales Amt"", [Sale Amt] ), 'Date'[Calendar Year] = 2006, FILTER(VALUES('Product'[Colour]), PATHCONTAINS(""BLACK|Blue|Multi"", 'Product'[Colour])) ) ORDER BY 'SalesTerritory'[SalesTerritory Country] desc, 'Product'[Colour] "; var formattedQry = @"EVALUATE CALCULATETABLE ( ADDCOLUMNS ( GENERATE ( GENERATE ( VALUES ( 'SalesTerritory'[SalesTerritory Country] ), VALUES ( 'Product'[Colour] ) ), VALUES ( 'Reseller'[BusinessType] ) ), ""Sales Amt"", [Sale Amt] ), 'Date'[Calendar Year] = 2006, FILTER ( VALUES ( 'Product'[Colour] ), PATHCONTAINS ( ""BLACK|Blue|Multi"", 'Product'[Colour] ) ) ) ORDER BY 'SalesTerritory'[SalesTerritory Country] DESC, 'Product'[Colour]"; var opt = new MockGlobalOptions() { DaxFormatterRequestTimeout = 10 }; DaxStudio.UI.Model.DaxFormatterResult res = await DaxStudio.UI.Model.DaxFormatterProxy.FormatDaxAsync(qry, opt); Assert.AreEqual(569, res.FormattedDax.Length, "Query length does not match"); Assert.AreEqual(formattedQry, res.FormattedDax, "Formatted Query does not match expected format"); Assert.IsNull(res.errors); }
public void TestDaxFormatterProxyWithInvalidQuery() { var qry = "evaluate values(tatatata "; //var req = new DaxStudio.UI.Model.DaxFormatterRequest(); //req.Dax = qry; var opt = new MockGlobalOptions() { DaxFormatterRequestTimeout = 10 }; var t = DaxStudio.UI.Model.DaxFormatterProxy.FormatDaxAsync(qry, opt); t.Wait(); DaxStudio.UI.Model.DaxFormatterResult res = t.Result; Assert.AreEqual(0, res.FormattedDax.Length); Assert.AreEqual(1, res.errors.Count); }
public async Task TestBackslashEscaping() { var mockGlobalOptions = new MockGlobalOptions() { ProxyUseSystem = true }; var mockEventAggregator = new MockEventAggregator(); var webReqFac = new UI.Utils.WebRequestFactory(mockGlobalOptions, mockEventAggregator); //var daxFmtProxy = IoC.BuildUp(webReqFac); var qry = "EVALUATE FILTER(Customer, Customer[Username] = \"Test\\User\")"; var expectedQry = "EVALUATE\r\nFILTER ( Customer, Customer[Username] = \"Test\\User\" )"; var opt = new MockGlobalOptions() { DaxFormatterRequestTimeout = 10 }; DaxStudio.UI.Model.DaxFormatterResult res = await DaxStudio.UI.Model.DaxFormatterProxy.FormatDaxAsync(qry, opt); Assert.AreEqual(expectedQry, res.FormattedDax); }