Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changes to allow special characters in parameter names #2481

Merged
merged 21 commits into from
Sep 1, 2020
Merged
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
d2d15ec
Introduced acceptance tests for default exclusion merging
cvpoienaru Jun 8, 2020
b9166b0
Merge branch 'master' into copoiena/testing-cc-default-exclusions
cvpoienaru Jun 29, 2020
598e583
Refactored acceptance tests
cvpoienaru Jun 29, 2020
57e56a5
Added .coverage report read & validation
cvpoienaru Jun 30, 2020
8a978bc
Added .coverage report transformation to XML
cvpoienaru Jul 1, 2020
13bb861
Changed CodeCoverage.exe path
cvpoienaru Jul 2, 2020
64a6412
Changed CodeCoverage.exe path
cvpoienaru Jul 2, 2020
d668e86
Merge branch 'master' into copoiena/testing-cc-default-exclusions
cvpoienaru Jul 2, 2020
8c369d6
Merged code coverage acceptance tests
cvpoienaru Jul 2, 2020
36a61b1
Fixed module name issue
cvpoienaru Jul 2, 2020
4c3f6c0
Reverted to two separate code coverage test files
cvpoienaru Jul 3, 2020
1a62904
Added module skip validation
cvpoienaru Jul 3, 2020
9e5de01
Changed skipped module name
cvpoienaru Jul 3, 2020
d16c034
Added test method
cvpoienaru Jul 7, 2020
710601b
Changes to allow special characters in parameter names
cvpoienaru Jul 13, 2020
771a9ff
Merge branch 'copoiena/special-chars-in-params' of https://github.com…
cvpoienaru Jul 13, 2020
47b2574
Changed test method name
cvpoienaru Jul 14, 2020
cbfa5d6
Merge branch 'master' into copoiena/special-chars-in-params
cvpoienaru Jul 21, 2020
458a38d
Merge branch 'master' into copoiena/special-chars-in-params
cvpoienaru Aug 31, 2020
b0f76e9
Changed method naming
cvpoienaru Aug 31, 2020
9ff7591
Stricter regex rules
cvpoienaru Aug 31, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public static void UpdateRunSettingsNode(this IRunSettingsProvider runSettingsPr
/// <returns></returns>
public static Match GetTestRunParameterNodeMatch(this IRunSettingsProvider runSettingsProvider, string node)
{
var attrName = $"(?<{AttributeNameString}>\\w+)";
var attrName = $"(?<{AttributeNameString}>(\\w+\\S*\\w+)|(\\w+))";
cvpoienaru marked this conversation as resolved.
Show resolved Hide resolved
var attrValue = $"(?<{AttributeValueString}>.+)";
Regex regex = new Regex($"{Constants.TestRunParametersName}.{ParameterString}\\(name\\s*=\\s*\"{attrName}\"\\s*,\\s*value\\s*=\\s*\"{attrValue}\"\\)");
Match match = regex.Match(node);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,13 +134,7 @@ public void UpdateRunSettingsNodeShouldAddNewKeyIfNotPresent()
[TestMethod]
public void UpdateTestRunParameterSettingsNodeShouldAddNewKeyIfNotPresent()
{
var match = this.runSettingsProvider.GetTestRunParameterNodeMatch("TestRunParameters.Parameter(name=\"weburl\",value=\"http://localhost//abc\")");
var runSettingsWithTestRunParameters = "<?xml version=\"1.0\" encoding=\"utf-16\"?>\r\n<RunSettings>\r\n <TestRunParameters>\r\n <Parameter name=\"weburl\" value=\"http://localhost//abc\" />\r\n </TestRunParameters>\r\n</RunSettings>";

this.runSettingsProvider.UpdateRunSettings("<RunSettings>\r\n </RunSettings>");
this.runSettingsProvider.UpdateTestRunParameterSettingsNode(match);

Assert.AreEqual(runSettingsWithTestRunParameters, this.runSettingsProvider.ActiveRunSettings.SettingsXml);
this.CheckRunSettingsAreUpdated("weburl", @"http://localhost//abc");
}

[TestMethod]
Expand All @@ -156,6 +150,18 @@ public void UpdateTetsRunParameterSettingsNodeShouldOverrideValueIfKeyIsAlreadyP
Assert.AreEqual(runSettingsWithTestRunParametersOverrode, this.runSettingsProvider.ActiveRunSettings.SettingsXml);
}

[TestMethod]
public void UpdateTestRunParameterSettingsNodeWithSpecialCharactersNameShouldSucceed()
cvpoienaru marked this conversation as resolved.
Show resolved Hide resolved
{
this.CheckRunSettingsAreUpdated("weburl:name", @"http://localhost//abc");
}

[TestMethod]
public void UpdateTestRunParameterSettingsNodeWithSingleCharacterNameShouldSucceed()
cvpoienaru marked this conversation as resolved.
Show resolved Hide resolved
{
this.CheckRunSettingsAreUpdated("a", @"http://localhost//abc");
}

[TestMethod]
public void UpdateRunSettingsNodeShouldUpdateKeyIfAlreadyPresent()
{
Expand Down Expand Up @@ -230,6 +236,17 @@ public void QueryRunSettingsNodeShouldReturnCorrectValue()
Assert.AreEqual("x86", this.runSettingsProvider.QueryRunSettingsNode("RunConfiguration.TargetPlatform"));
}

private void CheckRunSettingsAreUpdated(string parameterName, string parameterValue)
{
var match = this.runSettingsProvider.GetTestRunParameterNodeMatch($"TestRunParameters.Parameter(name=\"{parameterName}\",value=\"{parameterValue}\")");
var runSettingsWithTestRunParameters = $"<?xml version=\"1.0\" encoding=\"utf-16\"?>\r\n<RunSettings>\r\n <TestRunParameters>\r\n <Parameter name=\"{parameterName}\" value=\"{parameterValue}\" />\r\n </TestRunParameters>\r\n</RunSettings>";
cvpoienaru marked this conversation as resolved.
Show resolved Hide resolved

this.runSettingsProvider.UpdateRunSettings("<RunSettings>\r\n </RunSettings>");
this.runSettingsProvider.UpdateTestRunParameterSettingsNode(match);

Assert.AreEqual(runSettingsWithTestRunParameters, this.runSettingsProvider.ActiveRunSettings.SettingsXml);
}

private class TestableRunSettingsProvider : IRunSettingsProvider
{
public RunSettings ActiveRunSettings
Expand Down