mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-02-16 10:58:30 -05:00
Parsing nested properties in show plan nodes. (#1351)
* Parsing nested properties in show plan nodes. * Creating a base class for ExecutionGraphProp Adding a simple test to see if the nested props are parsed correctly. * Fixing doc comment * simplifying class name
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
using System;
|
||||
//
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
@@ -13,17 +14,40 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.ShowPlan
|
||||
{
|
||||
public class ShowPlanXMLTests
|
||||
{
|
||||
[Test]
|
||||
public void ParseXMLFileReturnsValidShowPlanGraph()
|
||||
private string queryPlanFileText;
|
||||
|
||||
[SetUp]
|
||||
public void LoadQueryPlanBeforeEachTest()
|
||||
{
|
||||
Assembly assembly = Assembly.GetAssembly(typeof(ShowPlanXMLTests));
|
||||
Stream scriptStream = assembly.GetManifestResourceStream(assembly.GetName().Name + ".ShowPlan.TestExecutionPlan.xml");
|
||||
StreamReader reader = new StreamReader(scriptStream);
|
||||
string text = reader.ReadToEnd();
|
||||
var showPlanGraphs = ShowPlanGraphUtils.CreateShowPlanGraph(text);
|
||||
queryPlanFileText = reader.ReadToEnd();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ParseXMLFileReturnsValidShowPlanGraph()
|
||||
{
|
||||
|
||||
var showPlanGraphs = ShowPlanGraphUtils.CreateShowPlanGraph(queryPlanFileText);
|
||||
Assert.AreEqual(1, showPlanGraphs.Count, "exactly one show plan graph should be returned");
|
||||
Assert.NotNull(showPlanGraphs[0], "graph should not be null");
|
||||
Assert.NotNull(showPlanGraphs[0].Root, "graph should have a root");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ParsingNestedProperties()
|
||||
{
|
||||
string[] commonNestedPropertiesNames = { "MemoryGrantInfo", "OptimizerHardwareDependentProperties" };
|
||||
var showPlanGraphs = ShowPlanGraphUtils.CreateShowPlanGraph(queryPlanFileText);
|
||||
ExecutionPlanNode rootNode = showPlanGraphs[0].Root;
|
||||
rootNode.Properties.ForEach(p =>
|
||||
{
|
||||
if (Array.FindIndex(commonNestedPropertiesNames, i => i.Equals(p.Name)) != -1 && (NestedExecutionPlanGraphProperty)p != null)
|
||||
{
|
||||
Assert.NotZero(((NestedExecutionPlanGraphProperty)p).Value.Count);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user