static public void BaseTestXml(string text, bool normalize = false) { var actual = BaseTest(text); var expected = text; if (normalize) { WindiffAssert.AreEqualNormalizedXmla(expected, actual); } else { WindiffAssert.AreEqual(expected, actual); } }
static public void BaseTestJson(string text, bool ignoreEmptyLines = false) { var actual = BaseTest(text); var expected = text; //Fix sorting. But missing properties in the model will be hidden. var database = JsonUtilities.Deserialize(expected); expected = JsonUtilities.Serialize(database); if (ignoreEmptyLines) { //Ignore empty lines. Parser not support whitespaces before expressions. WindiffAssert.AreEqualIgnoreEmptyLinesInExpressions(expected, actual); } else { WindiffAssert.AreEqual(expected, actual); } ValidateDatabase(text); }
public void TestProduceMeasuresCompatLevel1103() { #region expectedResultText string expectedResultText = @"<Alter ObjectExpansion=""ExpandFull"" xmlns=""http://schemas.microsoft.com/analysisservices/2003/engine""> <Object> <DatabaseID>de</DatabaseID> <CubeID>Model</CubeID> <MdxScriptID>MdxScript</MdxScriptID> </Object> <ObjectDefinition> <MdxScript> <ID>MdxScript</ID> <Name>MdxScript</Name> <Commands> <Command> <Text>CALCULATE; CREATE MEMBER CURRENTCUBE.Measures.[__XL_Count of Models] AS 1, VISIBLE = 0; ALTER CUBE CURRENTCUBE UPDATE DIMENSION Measures, Default_Member = [__XL_Count of Models]; </Text> </Command> <Command> <Text> ---------------------------------------------------------- -- PowerPivot measures command (do not modify manually) -- ---------------------------------------------------------- CREATE MEASURE 'Table1'[Measure 1]=1; </Text> <Annotations> <Annotation> <Name>FullName</Name> <Value>Measure 1</Value> </Annotation> <Annotation> <Name>Table</Name> <Value>Table1</Value> </Annotation> </Annotations> </Command> <Command> <Text> ---------------------------------------------------------- -- PowerPivot measures command (do not modify manually) -- ---------------------------------------------------------- CREATE MEASURE 'Table1'[MeasureCountRows]=COUNTROWS(Table1); </Text> <Annotations> <Annotation> <Name>FullName</Name> <Value>MeasureCountRows</Value> </Annotation> <Annotation> <Name>Table</Name> <Value>Table1</Value> </Annotation> </Annotations> </Command> </Commands> <CalculationProperties> <CalculationProperty> <Annotations> <Annotation> <Name>Type</Name> <Value>User</Value> </Annotation> <Annotation> <Name>IsPrivate</Name> <Value>False</Value> </Annotation> <Annotation> <Name>Format</Name> <Value> <Format Format=""General"" xmlns="""" /> </Value> </Annotation> </Annotations> <CalculationReference>[Measure 1]</CalculationReference> <CalculationType>Member</CalculationType> <FormatString>''</FormatString> </CalculationProperty> <CalculationProperty> <Annotations> <Annotation> <Name>Type</Name> <Value>User</Value> </Annotation> <Annotation> <Name>IsPrivate</Name> <Value>False</Value> </Annotation> <Annotation> <Name>Format</Name> <Value> <Format Format=""General"" xmlns="""" /> </Value> </Annotation> </Annotations> <CalculationReference>[MeasureCountRows]</CalculationReference> <CalculationType>Member</CalculationType> <FormatString>''</FormatString> </CalculationProperty> <CalculationProperty> <CalculationReference>[__XL_Count of Models]</CalculationReference> <CalculationType>Member</CalculationType> <Visible>false</Visible> </CalculationProperty> </CalculationProperties> </MdxScript> </ObjectDefinition> </Alter> "; #endregion var measures = new DaxMeasure[] { new DaxMeasure { TableName = "Table1", Name = "Measure 1", Expression = "1", FullText = "CREATE MEASURE 'Table1'[Measure 1]=1" }, new DaxMeasure { TableName = "Table1", Name = "MeasureCountRows", Expression = "COUNTROWS(Table1)", FullText = "CREATE MEASURE 'Table1'[MeasureCountRows]=COUNTROWS(Table1)" }, }; var cmdProducer = new ServerCommandProducer("de", 1103, "Model"); var actualResult = cmdProducer.ProduceAlterMdxScript(measures); var expected = XDocument.Parse(expectedResultText).ToString(SaveOptions.None); var actual = XDocument.Parse(actualResult).ToString(SaveOptions.None); WindiffAssert.AreEqual(expected, actual); }