public void GetResolvedRuleSetPath_FullPath_NonExistent() { MockEngine mockEngine = new MockEngine(); ResolveCodeAnalysisRuleSet task = new ResolveCodeAnalysisRuleSet(); task.BuildEngine = mockEngine; string codeAnalysisRuleSet = @"C:\foo\bar\CodeAnalysis.ruleset"; task.CodeAnalysisRuleSet = codeAnalysisRuleSet; task.MSBuildProjectDirectory = null; task.CodeAnalysisRuleSetDirectories = null; bool result = task.Execute(); string resolvedRuleSet = task.ResolvedCodeAnalysisRuleSet; Assert.AreEqual(expected: true, actual: result); Assert.AreEqual(expected: null, actual: resolvedRuleSet); mockEngine.AssertLogContains("MSB3884"); }
public void GetResolvedRuleSetPath_FullPath_Existent() { MockEngine mockEngine = new MockEngine(); ResolveCodeAnalysisRuleSet task = new ResolveCodeAnalysisRuleSet(); task.BuildEngine = mockEngine; string codeAnalysisRuleSet = Path.Combine(Path.GetTempPath(), @"CodeAnalysis.ruleset"); task.CodeAnalysisRuleSet = codeAnalysisRuleSet; task.MSBuildProjectDirectory = null; task.CodeAnalysisRuleSetDirectories = null; using (new TemporaryFile(codeAnalysisRuleSet, "foo")) { bool result = task.Execute(); string resolvedRuleSet = task.ResolvedCodeAnalysisRuleSet; Assert.AreEqual(expected: true, actual: result); Assert.AreEqual(expected: codeAnalysisRuleSet, actual: resolvedRuleSet); mockEngine.AssertLogDoesntContain("MSB3884"); } }
public void GetResolvedRuleSetPath_Null() { MockEngine mockEngine = new MockEngine(); ResolveCodeAnalysisRuleSet task = new ResolveCodeAnalysisRuleSet(); task.BuildEngine = mockEngine; task.CodeAnalysisRuleSet = null; task.MSBuildProjectDirectory = null; task.CodeAnalysisRuleSetDirectories = null; bool result = task.Execute(); string resolvedRuleSet = task.ResolvedCodeAnalysisRuleSet; Assert.AreEqual(expected: true, actual: result); Assert.AreEqual(expected: null, actual: resolvedRuleSet); mockEngine.AssertLogDoesntContain("MSB3884"); }
public void GetResolvedRuleSetPath_RelativePath_NoProject() { MockEngine mockEngine = new MockEngine(); ResolveCodeAnalysisRuleSet task = new ResolveCodeAnalysisRuleSet(); task.BuildEngine = mockEngine; string subdirectoryName = Path.GetRandomFileName(); task.CodeAnalysisRuleSet = Path.Combine(subdirectoryName, "CodeAnalysis.ruleset"); task.MSBuildProjectDirectory = null; task.CodeAnalysisRuleSetDirectories = null; bool result = task.Execute(); string resolvedRuleSet = task.ResolvedCodeAnalysisRuleSet; Assert.AreEqual(expected: true, actual: result); Assert.AreEqual(expected: null, actual: resolvedRuleSet); mockEngine.AssertLogContains("MSB3884"); }
public void GetResolvedRuleSetPath_RelativePath_WithProject_Existent() { MockEngine mockEngine = new MockEngine(); ResolveCodeAnalysisRuleSet task = new ResolveCodeAnalysisRuleSet(); task.BuildEngine = mockEngine; string subdirectoryName = Path.GetRandomFileName(); string codeAnalysisRuleSet = Path.Combine(subdirectoryName, "CodeAnalysis.ruleset"); string projectDirectory = Path.GetTempPath(); task.CodeAnalysisRuleSet = codeAnalysisRuleSet; task.MSBuildProjectDirectory = projectDirectory; task.CodeAnalysisRuleSetDirectories = null; string ruleSetFullPath = Path.Combine(projectDirectory, codeAnalysisRuleSet); using (new TemporaryDirectory(Path.GetDirectoryName(ruleSetFullPath))) using (new TemporaryFile(ruleSetFullPath, "foo")) { bool result = task.Execute(); string resolvedRuleSet = task.ResolvedCodeAnalysisRuleSet; Assert.AreEqual(expected: true, actual: result); Assert.AreEqual(expected: codeAnalysisRuleSet, actual: resolvedRuleSet); mockEngine.AssertLogDoesntContain("MSB3884"); } }
public void GetResolvedRuleSetPath_SimpleNameAndDirectories_NonExistent() { MockEngine mockEngine = new MockEngine(); ResolveCodeAnalysisRuleSet task = new ResolveCodeAnalysisRuleSet(); task.BuildEngine = mockEngine; string directory = Path.GetTempPath(); task.CodeAnalysisRuleSet = Path.GetRandomFileName() + ".ruleset"; task.MSBuildProjectDirectory = null; task.CodeAnalysisRuleSetDirectories = new[] { directory }; bool result = task.Execute(); string resolvedRuleSet = task.ResolvedCodeAnalysisRuleSet; Assert.AreEqual(expected: true, actual: result); Assert.AreEqual(expected: null, actual: resolvedRuleSet); mockEngine.AssertLogContains("MSB3884"); }
public void GetResolvedRuleSetPath_SimpleNameAndDirectories_Existent() { MockEngine mockEngine = new MockEngine(); ResolveCodeAnalysisRuleSet task = new ResolveCodeAnalysisRuleSet(); task.BuildEngine = mockEngine; string codeAnalysisRuleSet = @"CodeAnalysis.ruleset"; var directory = Path.GetTempPath(); task.CodeAnalysisRuleSet = codeAnalysisRuleSet; task.MSBuildProjectDirectory = null; task.CodeAnalysisRuleSetDirectories = new[] { directory }; string ruleSetFullPath = Path.Combine(directory, codeAnalysisRuleSet); using (new TemporaryFile(ruleSetFullPath, "foo")) { bool result = task.Execute(); string resolvedRuleSet = task.ResolvedCodeAnalysisRuleSet; Assert.Equal(expected: true, actual: result); Assert.Equal(expected: ruleSetFullPath, actual: resolvedRuleSet); mockEngine.AssertLogDoesntContain("MSB3884"); } }