Skip to content

Commit

Permalink
Updated tests according to the logic change (#1026)
Browse files Browse the repository at this point in the history
  • Loading branch information
jiarima authored Jul 30, 2020
1 parent 22eba13 commit 655e064
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/Microsoft.InsightsGenerator/RulesEngine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public static ColumnHeaders TemplateParser(string templateContent)
string headers = s.Substring(1, s.Length - 1);
if (headers.StartsWith("#"))
{
ch.DoubleHashValues.Add(headers.Substring(1, headers.Length - 1));
ch.DoubleHashValues.Add( "##" + headers.Substring(1, headers.Length - 1));
}
else
{
Expand Down
16 changes: 8 additions & 8 deletions test/Microsoft.InsightsGenerator.UnitTests/RulesEngineTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ public void TemplateParserTest()
ColumnHeaders headerForTemp8 = TemplateParser(@"#inp had a total of #OutPar_N_C_1 ##OutPar_N_C_1 that constitues #Per% \n \n");
ColumnHeaders headerForTemp16 = TemplateParser(@"For the #slices ##SlicePar_GG_1(s), the percentage of ##OutPar_N_C_1 on #time were \n #stHData\n this was compared with #Etime where #ESlices ##SlicePar_GG_1\n #EstHData \n.");

var expectedSingleHashValuesForTemp16 = new List<string>(new string[] {"slices", "time", "stHData", "Etime", "ESlices", "EstHData" });
var expectedDoubleHashValuesForTemp16 = new List<string>(new string[] { "SlicePar_GG_1(s)", "OutPar_N_C_1", "SlicePar_GG_1" });
var expectedSingleHashValuesForTemp16 = new List<string>(new string[] { "#slices", "#time", "#stHData", "#Etime", "#ESlices", "#EstHData" });
var expectedDoubleHashValuesForTemp16 = new List<string>(new string[] { "##SlicePar_GG_1(s)", "##OutPar_N_C_1", "##SlicePar_GG_1" });

var expectedSingleHashValuesForTemp8 = new List<string>(new string[] { "#inp", "#OutPar_N_C_1", "#Per%" });
var expectedDoubleHashValuesForTemp8 = new List<string>(new string[] { "##OutPar_N_C_1" });

var expectedSingleHashValuesForTemp8 = new List<string>(new string[] { "inp", "OutPar_N_C_1", "Per%" });
var expectedDoubleHashValuesForTemp8 = new List<string>(new string[] { "OutPar_N_C_1" });

Assert.True(Enumerable.SequenceEqual(expectedSingleHashValuesForTemp8, headerForTemp8.SingleHashValues));
Assert.True(Enumerable.SequenceEqual(expectedDoubleHashValuesForTemp8, headerForTemp8.DoubleHashValues));
Assert.True(Enumerable.SequenceEqual(expectedSingleHashValuesForTemp16, headerForTemp16.SingleHashValues));
Expand All @@ -37,14 +37,14 @@ public void TemplateParserTest()
public void RulesEngineEndToEndTest()
{
var singleHashList = new List<List<string>>();
var list1 = new List<string>() { "uniqueinputs", "15"};
var list1 = new List<string>() { "uniqueinputs", "15" };
var list2 = new List<string>() { "top", "3", "China: 55%", "United States: 49%", "Japan: 37%" };
singleHashList.Add(list1);
singleHashList.Add(list2);

DataArray test = new DataArray();
test.ColumnNames = new string[]{ "Country", "Area" };
test.TransformedColumnNames = new string []{ "input_g_0", "Output_0" };
test.ColumnNames = new string[] { "Country", "Area" };
test.TransformedColumnNames = new string[] { "input_g_0", "Output_0" };

var str = RulesEngine.FindMatchedTemplate(singleHashList, test);
//The ##InPar_GG_1 that had the largest of each ##SlicePar_GG_1 are \n
Expand Down

0 comments on commit 655e064

Please sign in to comment.