Skip to content

Commit 5cb4d2a

Browse files
authored
enabling disabled tests (Azure#3229)
* enabling disabled tests * updating test category as CheckinTests. Fixed the cmdlet directory path to be included while running static analysis on test cmdlet assembly
1 parent a3dff10 commit 5cb4d2a

File tree

1 file changed

+40
-28
lines changed

1 file changed

+40
-28
lines changed

tools/StaticAnalysis/StaticAnalysis.Test/SignatureVerifierTests.cs

Lines changed: 40 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ namespace StaticAnalysis.Test
99
using Xunit;
1010
using System.Linq;
1111
using StaticAnalysis.ProblemIds;
12+
using System.Reflection;
1213

1314
/// <summary>
1415
/// Add a way to send filterDirectory, FiltercmdLets delegates to the analyze method.
@@ -20,30 +21,31 @@ namespace StaticAnalysis.Test
2021
/// </summary>
2122
public class SignatureVerifierTests
2223
{
23-
string testCmdletDirPath, exceptionsDirPath;
24+
string _testCmdletDirPath, _exceptionsDirPath;
2425
SignatureVerifier.SignatureVerifier cmdletSignatureVerifier;
2526
AnalysisLogger analysisLogger;
2627

2728
public SignatureVerifierTests()
2829
{
29-
testCmdletDirPath = System.Environment.CurrentDirectory;
30-
exceptionsDirPath = Path.Combine(testCmdletDirPath, "Exceptions");
30+
_testCmdletDirPath = Path.GetDirectoryName(new Uri(Assembly.GetExecutingAssembly().CodeBase).AbsolutePath);
31+
_exceptionsDirPath = Path.Combine(_testCmdletDirPath, "Exceptions");
3132

32-
analysisLogger = new AnalysisLogger(testCmdletDirPath, exceptionsDirPath);
33+
analysisLogger = new AnalysisLogger(_testCmdletDirPath, _exceptionsDirPath);
3334
cmdletSignatureVerifier = new StaticAnalysis.SignatureVerifier.SignatureVerifier();
3435
cmdletSignatureVerifier.Logger = analysisLogger;
3536
}
3637

3738
#region Verb Cmdlets and SupportsShouldProcess
3839
/// <summary>
3940
///
40-
/// </summary>
41-
[Fact(Skip = "See Azure PowerShell issue #2987 - https://github.com/Azure/azure-powershell/issues/2987")]
41+
/// </summary>
42+
[Fact]
43+
[Trait(Category.AcceptanceType, Category.CheckIn)]
4244
public void AddVerbWithoutSupportsShouldProcessParameter()
4345
{
4446
cmdletSignatureVerifier.Analyze(
45-
new List<string> { Environment.CurrentDirectory },
46-
((dirList) => { return new List<string> { Environment.CurrentDirectory }; }),
47+
new List<string> { _testCmdletDirPath},
48+
((dirList) => { return new List<string> { _testCmdletDirPath}; }),
4749
(cmdletName) => cmdletName.Equals("Add-AddVerbWithoutSupportsShouldProcessParameter", StringComparison.OrdinalIgnoreCase));
4850

4951
AnalysisReport testReport = cmdletSignatureVerifier.GetAnalysisReport();
@@ -53,11 +55,12 @@ public void AddVerbWithoutSupportsShouldProcessParameter()
5355
}
5456

5557
[Fact]
58+
[Trait(Category.AcceptanceType, Category.CheckIn)]
5659
public void AddVerbWithSupportsShouldProcessParameter()
5760
{
5861
cmdletSignatureVerifier.Analyze(
59-
new List<string> { Environment.CurrentDirectory },
60-
((dirList) => { return new List<string> { Environment.CurrentDirectory }; }),
62+
new List<string> { _testCmdletDirPath},
63+
((dirList) => { return new List<string> { _testCmdletDirPath}; }),
6164
(cmdletName) => cmdletName.Equals("Add-AddVerbWithSupportsShouldProcessParameter", StringComparison.OrdinalIgnoreCase));
6265

6366
AnalysisReport testReport = cmdletSignatureVerifier.GetAnalysisReport();
@@ -67,26 +70,31 @@ public void AddVerbWithSupportsShouldProcessParameter()
6770
#endregion
6871

6972
#region ForceSwitch and SupportsShouldProcess
70-
71-
[Fact(Skip = "See Azure PowerShell issue #2987 - https://github.com/Azure/azure-powershell/issues/2987")]
73+
74+
[Fact]
75+
[Trait(Category.AcceptanceType, Category.CheckIn)]
7276
public void ForceParameterWithoutSupportsShouldProcess()
7377
{
7478
cmdletSignatureVerifier.Analyze(
75-
new List<string> { Environment.CurrentDirectory },
76-
((dirList) => { return new List<string> { Environment.CurrentDirectory }; }),
79+
new List<string> { _testCmdletDirPath },
80+
((dirList) => { return new List<string> { _testCmdletDirPath}; }),
7781
(cmdletName) => cmdletName.Equals("Test-ForceParameterWithoutSupportsShouldProcess", StringComparison.OrdinalIgnoreCase));
7882

83+
analysisLogger.Info("Foo");
84+
85+
7986
AnalysisReport testReport = cmdletSignatureVerifier.GetAnalysisReport();
8087
Assert.True(testReport.ProblemIdList.Count == 1);
8188
Assert.True(testReport.ProblemIdList.Where<int>((problemId) => problemId.Equals(SignatureProblemId.ForceWithoutShouldProcessAttribute)).SingleOrDefault<int>().Equals(SignatureProblemId.ForceWithoutShouldProcessAttribute));
8289
}
8390

8491
[Fact]
92+
[Trait(Category.AcceptanceType, Category.CheckIn)]
8593
public void ForceParameterWithSupportsShouldProcess()
8694
{
8795
cmdletSignatureVerifier.Analyze(
88-
new List<string> { Environment.CurrentDirectory },
89-
((dirList) => { return new List<string> { Environment.CurrentDirectory }; }),
96+
new List<string> { _testCmdletDirPath },
97+
((dirList) => { return new List<string> { _testCmdletDirPath}; }),
9098
(cmdletName) => cmdletName.Equals("Test-ForceParameterWithSupportsShouldProcess", StringComparison.OrdinalIgnoreCase));
9199

92100
AnalysisReport testReport = cmdletSignatureVerifier.GetAnalysisReport();
@@ -97,23 +105,25 @@ public void ForceParameterWithSupportsShouldProcess()
97105

98106
#region ConfirmImpact and SupportsShouldProcess
99107
[Fact]
108+
[Trait(Category.AcceptanceType, Category.CheckIn)]
100109
public void ConfirmImpactWithSupportsShouldProcess()
101110
{
102111
cmdletSignatureVerifier.Analyze(
103-
new List<string> { Environment.CurrentDirectory },
104-
((dirList) => { return new List<string> { Environment.CurrentDirectory }; }),
112+
new List<string> { _testCmdletDirPath },
113+
((dirList) => { return new List<string> { _testCmdletDirPath}; }),
105114
(cmdletName) => cmdletName.Equals("Test-ConfirmImpactWithSupportsShouldProcess", StringComparison.OrdinalIgnoreCase));
106115

107116
AnalysisReport testReport = cmdletSignatureVerifier.GetAnalysisReport();
108117
Assert.True(testReport.ProblemIdList.Count == 0);
109118
}
110-
111-
[Fact(Skip = "See Azure PowerShell issue #2987 - https://github.com/Azure/azure-powershell/issues/2987")]
119+
120+
[Fact]
121+
[Trait(Category.AcceptanceType, Category.CheckIn)]
112122
public void ConfirmImpactWithoutSupportsShouldProcess()
113123
{
114124
cmdletSignatureVerifier.Analyze(
115-
new List<string> { Environment.CurrentDirectory },
116-
((dirList) => { return new List<string> { Environment.CurrentDirectory }; }),
125+
new List<string> { _testCmdletDirPath },
126+
((dirList) => { return new List<string> { _testCmdletDirPath}; }),
117127
(cmdletName) => cmdletName.Equals("Test-ConfirmImpactWithoutSupportsShouldProcess", StringComparison.OrdinalIgnoreCase));
118128

119129
AnalysisReport testReport = cmdletSignatureVerifier.GetAnalysisReport();
@@ -125,23 +135,25 @@ public void ConfirmImpactWithoutSupportsShouldProcess()
125135

126136
#region IsShouldContinueVerb and ForceSwitch
127137
[Fact]
138+
[Trait(Category.AcceptanceType, Category.CheckIn)]
128139
public void ShouldContinueVerbWithForceSwitch()
129140
{
130141
cmdletSignatureVerifier.Analyze(
131-
new List<string> { Environment.CurrentDirectory },
132-
((dirList) => { return new List<string> { Environment.CurrentDirectory }; }),
142+
new List<string> { _testCmdletDirPath },
143+
((dirList) => { return new List<string> { _testCmdletDirPath}; }),
133144
(cmdletName) => cmdletName.Equals("Copy-ShouldContinueVerbWithForceSwitch", StringComparison.OrdinalIgnoreCase));
134145

135146
AnalysisReport testReport = cmdletSignatureVerifier.GetAnalysisReport();
136147
Assert.True(testReport.ProblemIdList.Count == 0);
137148
}
138-
139-
[Fact(Skip = "See Azure PowerShell issue #2987 - https://github.com/Azure/azure-powershell/issues/2987")]
149+
150+
[Fact]
151+
[Trait(Category.AcceptanceType, Category.CheckIn)]
140152
public void ShouldContinueVerbWithoutForceSwitch()
141153
{
142154
cmdletSignatureVerifier.Analyze(
143-
new List<string> { Environment.CurrentDirectory },
144-
((dirList) => { return new List<string> { Environment.CurrentDirectory }; }),
155+
new List<string> { _testCmdletDirPath },
156+
((dirList) => { return new List<string> { _testCmdletDirPath}; }),
145157
(cmdletName) => cmdletName.Equals("Export-ShouldContinueVerbWithoutForceSwitch", StringComparison.OrdinalIgnoreCase));
146158

147159
AnalysisReport testReport = cmdletSignatureVerifier.GetAnalysisReport();

0 commit comments

Comments
 (0)