Skip to content

Commit 7d4c2e7

Browse files
committed
Add test to ensure no exceptions are thrown for parameter replaced by alias
1 parent 48de6dd commit 7d4c2e7

File tree

5 files changed

+1907
-200
lines changed

5 files changed

+1907
-200
lines changed
Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1 @@
1-
"AssemblyFileName","ClassName","Target","Severity","ProblemId","Description","Remediation"
2-
"Microsoft.Azure.Commands.Profile.dll","Microsoft.Azure.Commands.Profile.ConnectAzureRmAccountCommand","Connect-AzureRmAccount","0","1050","The parameter set 'ServicePrincipalWithSubscriptionId' for cmdlet 'Connect-AzureRmAccount' has been removed.","Add parameter set 'ServicePrincipalWithSubscriptionId' back to cmdlet 'Connect-AzureRmAccount'."
3-
"Microsoft.Azure.Commands.Profile.dll","Microsoft.Azure.Commands.Profile.ConnectAzureRmAccountCommand","Connect-AzureRmAccount","0","1050","The parameter set 'ServicePrincipalCertificateWithSubscriptionId' for cmdlet 'Connect-AzureRmAccount' has been removed.","Add parameter set 'ServicePrincipalCertificateWithSubscriptionId' back to cmdlet 'Connect-AzureRmAccount'."
1+
"AssemblyFileName","ClassName","Target","Severity","ProblemId","Description","Remediation"
Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1 @@
1-
"AssemblyFileName","ClassName","Target","Severity","ProblemId","Description","Remediation"
2-
"Microsoft.Azure.Commands.Profile.dll","Microsoft.Azure.Commands.Profile.ConnectAzureRmAccountCommand","Connect-AzureRmAccount","0","1050","The parameter set 'ServicePrincipalWithSubscriptionId' for cmdlet 'Connect-AzureRmAccount' has been removed.","Add parameter set 'ServicePrincipalWithSubscriptionId' back to cmdlet 'Connect-AzureRmAccount'."
3-
"Microsoft.Azure.Commands.Profile.dll","Microsoft.Azure.Commands.Profile.ConnectAzureRmAccountCommand","Connect-AzureRmAccount","0","1050","The parameter set 'ServicePrincipalCertificateWithSubscriptionId' for cmdlet 'Connect-AzureRmAccount' has been removed.","Add parameter set 'ServicePrincipalCertificateWithSubscriptionId' back to cmdlet 'Connect-AzureRmAccount'."
1+
"AssemblyFileName","ClassName","Target","Severity","ProblemId","Description","Remediation"

tools/StaticAnalysis/StaticAnalysis.Test/BreakingChangeAnalyzerTests.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -832,5 +832,19 @@ public void ChangeValidateRangeMaximum()
832832
.Where<int>((problemId) => problemId.Equals(BreakingChangeProblemId.ChangedValidateRangeMaximum))
833833
.SingleOrDefault<int>().Equals(BreakingChangeProblemId.ChangedValidateRangeMaximum));
834834
}
835+
836+
[Fact]
837+
[Trait(Category.AcceptanceType, Category.CheckIn)]
838+
public void ParameterReplacedByAlias()
839+
{
840+
cmdletBreakingChangeAnalyzer.Analyze(
841+
new List<string> { _testCmdletDirPath },
842+
((dirList) => { return new List<string> { _testCmdletDirPath }; }),
843+
(cmdletName) => cmdletName.Equals("Test-ParameterReplacedByAlias", StringComparison.OrdinalIgnoreCase));
844+
845+
AnalysisReport testReport = cmdletBreakingChangeAnalyzer.GetAnalysisReport();
846+
847+
Assert.Equal(0, testReport.ProblemIdList.Count);
848+
}
835849
}
836850
}

tools/StaticAnalysis/StaticAnalysis.Test/TestCmdlets/BreakingChangeAnalyzer_Cmdlet.cs

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -477,7 +477,7 @@ namespace StaticAnalysis.Test.CmdletTest.BreakingChange.ChangeOutputGenericTypeA
477477
using System.Collections.Generic;
478478
using System.Management.Automation;
479479

480-
[Cmdlet(VerbsDiagnostic.Test, "ChangeOutputGenericTypeArgument"), OutputType(typeof(string))]
480+
[Cmdlet(VerbsDiagnostic.Test, "ChangeOutputGenericTypeArgument"), OutputType(typeof(List<string>))]
481481
public class TestChangeOutputGenericTypeArgument : Cmdlet
482482
{
483483
protected override void BeginProcessing()
@@ -758,4 +758,24 @@ protected override void BeginProcessing()
758758
WriteInformation("Info", null);
759759
}
760760
}
761+
}
762+
763+
namespace StaticAnalysis.Test.CmdletTest.BreakingChange.ParameterReplacedByAlias
764+
{
765+
using System.Collections.Generic;
766+
using System.Management.Automation;
767+
768+
[Cmdlet(VerbsDiagnostic.Test, "ParameterReplacedByAlias")]
769+
public class TestDifferentGenericTypeArgumentSize : Cmdlet
770+
{
771+
[Parameter(Mandatory = true)]
772+
[Alias("Parameter")]
773+
public string Param { get; set; }
774+
775+
protected override void BeginProcessing()
776+
{
777+
WriteObject("Test-ParameterReplacedByAlias BeginProcessing()");
778+
WriteInformation("Info", null);
779+
}
780+
}
761781
}

0 commit comments

Comments
 (0)