public void FxCopConverter_CreateResult_FakeContext_Resource() { var context = TestHelper.CreateProjectContext(); context.RefineTarget(@"mybinary.dll"); context.RefineModule("mybinary.dll"); context.RefineResource("myresource.resx"); context.RefineMessage("CA0000", "VeryUsefulCheck", null, null, null, null); context.RefineIssue("hello!", "test", null, null, @"source", "myfile.cs", 13); var expectedLogicalLocations = new List <LogicalLocation> { new LogicalLocation { Kind = LogicalLocationKind.Module, Name = "mybinary.dll" }, new LogicalLocation { ParentIndex = 0, Name = "myresource.resx", FullyQualifiedName = "mybinary.dll!myresource.resx", Kind = LogicalLocationKind.Resource } }; var converter = new FxCopConverter(); Result result = converter.CreateResult(context); ValidateLogicalLocations(expectedLogicalLocations, converter.LogicalLocations); }
public void FxCopConverter_CreateResult_FakeContext_Resource() { var context = TestHelper.CreateProjectContext(); context.RefineTarget(@"mybinary.dll"); context.RefineModule("mybinary.dll"); context.RefineResource("myresource.resx"); context.RefineMessage("CA0000", "VeryUsefulCheck", null, null, null, null); context.RefineIssue("hello!", "test", null, null, @"source", "myfile.cs", 13); var expectedLogicalLocations = new Dictionary <string, LogicalLocation> { { "mybinary.dll", new LogicalLocation { ParentKey = null, Kind = LogicalLocationKind.Module } }, { "mybinary.dll!myresource.resx", new LogicalLocation { ParentKey = "mybinary.dll", Name = "myresource.resx", Kind = LogicalLocationKind.Resource } }, }; var converter = new FxCopConverter(); Result result = converter.CreateResult(context); foreach (string key in expectedLogicalLocations.Keys) { expectedLogicalLocations[key].ValueEquals(converter.LogicalLocationsDictionary[key]).Should().BeTrue(); } converter.LogicalLocationsDictionary.Count.Should().Be(expectedLogicalLocations.Count); }
public void FxCopConverter_CreateResult_FakeContext_NoModule_Member() { var context = TestHelper.CreateProjectContext(); context.RefineTarget(@"mybinary.dll"); context.RefineNamespace("mynamespace"); context.RefineType("mytype"); context.RefineMember("mymember(string)"); context.RefineMessage("CA0000", "VeryUsefulCheck", null, null, null, null); context.RefineIssue("hello!", null, null, null, null, null, null); var expectedLogicalLocations = new List <LogicalLocation> { new LogicalLocation { ParentIndex = -1, Name = "mynamespace", Kind = LogicalLocationKind.Namespace }, new LogicalLocation { ParentIndex = 0, Name = "mytype", FullyQualifiedName = "mynamespace.mytype", Kind = LogicalLocationKind.Type }, new LogicalLocation { ParentIndex = 1, Name = "mymember(string)", FullyQualifiedName = "mynamespace.mytype.mymember(string)", Kind = LogicalLocationKind.Member } }; var converter = new FxCopConverter(); Result result = converter.CreateResult(context); ValidateLogicalLocations(expectedLogicalLocations, converter.LogicalLocations); }
public void FxCopConverter_CreateIssue_FakeContext_NoModule_Member() { var context = TestHelper.CreateProjectContext(); context.RefineTarget(@"mybinary.dll"); context.RefineNamespace("mynamespace"); context.RefineType("mytype"); context.RefineMember("mymember(string)"); context.RefineMessage("CA0000", "VeryUsefulCheck", null, null, null, null); context.RefineIssue("hello!", null, null, null, null, null, null); var expectedLogicalLocation = "mynamespace.mytype.mymember(string)"; var expectedLocations = new[] { new Location { AnalysisTarget = new PhysicalLocation { Uri = new Uri("mybinary.dll", UriKind.RelativeOrAbsolute), }, FullyQualifiedLogicalName = expectedLogicalLocation } }; var expectedLogicalLocations = new Dictionary <string, LogicalLocation> { { "mynamespace", new LogicalLocation { ParentKey = null, Name = "mynamespace", Kind = LogicalLocationKind.Namespace } }, { "mynamespace.mytype", new LogicalLocation { ParentKey = "mynamespace", Name = "mytype", Kind = LogicalLocationKind.Type } }, { "mynamespace.mytype.mymember(string)", new LogicalLocation { ParentKey = "mynamespace.mytype", Name = "mymember(string)", Kind = LogicalLocationKind.Member } } }; var converter = new FxCopConverter(); Result result = converter.CreateResult(context); foreach (string key in expectedLogicalLocations.Keys) { expectedLogicalLocations[key].ValueEquals(converter.LogicalLocationsDictionary[key]).Should().BeTrue(); } converter.LogicalLocationsDictionary.Count.Should().Be(expectedLogicalLocations.Count); }
public void FxCopConverter_CreateResult_FakeContext_Resource() { var context = TestHelper.CreateProjectContext(); context.RefineTarget(@"mybinary.dll"); context.RefineModule("mybinary.dll"); context.RefineResource("myresource.resx"); context.RefineMessage("CA0000", "VeryUsefulCheck", null, null, null, null); context.RefineIssue("hello!", "test", null, null, @"source", "myfile.cs", 13); var expectedLogicalLocation = "myresource.resx"; var expectedLocations = new[] { new Location { AnalysisTarget = new PhysicalLocation { Uri = new Uri("mybinary.dll", UriKind.RelativeOrAbsolute), }, ResultFile = new PhysicalLocation { Uri = new Uri("source\\myfile.cs", UriKind.RelativeOrAbsolute), Region = new Region { StartLine = 13 } }, FullyQualifiedLogicalName = expectedLogicalLocation, } }; var expectedLogicalLocations = new Dictionary <string, LogicalLocation> { { "mybinary.dll", new LogicalLocation { ParentKey = null, Name = "mybinary.dll", Kind = LogicalLocationKind.Module } }, { "mybinary.dll!myresource.resx", new LogicalLocation { ParentKey = "mybinary.dll", Name = "myresource.resx", Kind = LogicalLocationKind.Resource } }, }; var converter = new FxCopConverter(); Result result = converter.CreateResult(context); foreach (string key in expectedLogicalLocations.Keys) { expectedLogicalLocations[key].ValueEquals(converter.LogicalLocationsDictionary[key]).Should().BeTrue(); } converter.LogicalLocationsDictionary.Count.Should().Be(expectedLogicalLocations.Count); }
public void FxCopConverter_CreateResult_FakeContext_Resource() { var context = TestHelper.CreateProjectContext(); context.RefineTarget(@"mybinary.dll"); context.RefineModule("mybinary.dll"); context.RefineResource("myresource.resx"); context.RefineMessage("CA0000", "VeryUsefulCheck", null, null, null); context.RefineIssue("hello!", "test", null, null, @"source", "myfile.cs", 13); var expectedLogicalLocation = "myresource.resx"; var expectedLocations = new[] { new Location { AnalysisTarget = new PhysicalLocation { Uri = new Uri("mybinary.dll", UriKind.RelativeOrAbsolute), }, ResultFile = new PhysicalLocation { Uri = new Uri("source\\myfile.cs", UriKind.RelativeOrAbsolute), Region = new Region { StartLine = 13 } }, FullyQualifiedLogicalName = expectedLogicalLocation, } }; var expectedLogicalLocationComponents = new[] { new LogicalLocationComponent { Name = "mybinary.dll", Kind = LogicalLocationKind.Module }, new LogicalLocationComponent { Name = "myresource.resx", Kind = LogicalLocationKind.Resource } }; var converter = new FxCopConverter(); Result result = converter.CreateResult(context); result.Locations.Should().Equal(expectedLocations); converter.LogicalLocationsDictionary.Keys.Should().ContainSingle(expectedLogicalLocation); var actualLogicalLocationComponents = converter.LogicalLocationsDictionary[expectedLogicalLocation]; actualLogicalLocationComponents.Should().Equal(expectedLogicalLocationComponents); }
public void FxCopConverter_CreateIssue_FakeContext_NoModule_Member() { var context = TestHelper.CreateProjectContext(); context.RefineTarget(@"mybinary.dll"); context.RefineNamespace("mynamespace"); context.RefineType("mytype"); context.RefineMember("mymember(string)"); context.RefineMessage("CA0000", "VeryUsefulCheck", null, null, null); context.RefineIssue("hello!", null, null, null, null, null, null); var expectedLogicalLocation = "mynamespace.mytype.mymember(string)"; var expectedLocations = new[] { new Location { AnalysisTarget = new PhysicalLocation { Uri = new Uri("mybinary.dll", UriKind.RelativeOrAbsolute), }, FullyQualifiedLogicalName = expectedLogicalLocation } }; var expectedLogicalLocationComponents = new[] { new LogicalLocationComponent { Name = "mynamespace", Kind = LogicalLocationKind.Namespace }, new LogicalLocationComponent { Name = "mytype", Kind = LogicalLocationKind.Type }, new LogicalLocationComponent { Name = "mymember(string)", Kind = LogicalLocationKind.Member } }; var converter = new FxCopConverter(); Result result = converter.CreateResult(context); result.Locations.Should().Equal(expectedLocations); converter.LogicalLocationsDictionary.Keys.Should().ContainSingle(expectedLogicalLocation); var actualLogicalLocationComponents = converter.LogicalLocationsDictionary[expectedLogicalLocation]; actualLogicalLocationComponents.Should().Equal(expectedLogicalLocationComponents); }
public void FxCopConverter_CreateResult_FakeContext_NoModule_Resource() { var context = TestHelper.CreateProjectContext(); context.RefineTarget(@"mybinary.dll"); context.RefineResource("myresource.resx"); context.RefineMessage("CA0000", "VeryUsefulCheck", null, null, null, null); context.RefineIssue("hello!", "test", null, null, null, null, null); var converter = new FxCopConverter(); Result result = converter.CreateResult(context); result.Locations.First().LogicalLocation.FullyQualifiedName.Should().Be(@"myresource.resx"); }
public void FxCopConverter_CreateResult_FakeContext_Member() { var context = TestHelper.CreateProjectContext(); context.RefineTarget(@"mybinary.dll"); context.RefineModule("mybinary.dll"); context.RefineNamespace("mynamespace"); context.RefineType("mytype"); context.RefineMember("mymember(string)"); context.RefineMessage("CA0000", "VeryUsefulCheck", "1", "FakeCategory", "Breaking", "ExcludedInSource"); context.RefineIssue(null, "test", "uncertain", "error", @"source", "myfile.cs", 13); context.RefineItem("hello!"); string expectedLogicalLocation = "mynamespace.mytype.mymember(string)"; var expectedResult = new Result { RuleId = "CA0000", Message = new Message { Arguments = new List <string>(new string[] { "hello!" }) }, Suppressions = new List <Suppression> { new Suppression { Kind = SuppressionKind.InSource } }, PartialFingerprints = new Dictionary <string, string>(), AnalysisTarget = new ArtifactLocation { Uri = new Uri("mybinary.dll", UriKind.RelativeOrAbsolute), }, Locations = new List <Location> { new Location { PhysicalLocation = new PhysicalLocation { ArtifactLocation = new ArtifactLocation { Uri = new Uri("source\\myfile.cs", UriKind.RelativeOrAbsolute) }, Region = new Region { StartLine = 13 } }, LogicalLocation = new LogicalLocation { FullyQualifiedName = expectedLogicalLocation, Index = 3 } } } }; expectedResult.PartialFingerprints.Add("UniqueId", "1#test"); expectedResult.SetProperty("Level", "error"); expectedResult.SetProperty("Category", "FakeCategory"); expectedResult.SetProperty("FixCategory", "Breaking"); var expectedLogicalLocations = new List <LogicalLocation> { new LogicalLocation { ParentIndex = -1, Name = "mybinary.dll", Kind = LogicalLocationKind.Module }, new LogicalLocation { ParentIndex = 0, Name = "mynamespace", FullyQualifiedName = "mybinary.dll!mynamespace", Kind = LogicalLocationKind.Namespace }, new LogicalLocation { ParentIndex = 1, Name = "mytype", FullyQualifiedName = "mybinary.dll!mynamespace.mytype", Kind = LogicalLocationKind.Type }, new LogicalLocation { ParentIndex = 2, Name = "mymember(string)", FullyQualifiedName = "mybinary.dll!mynamespace.mytype.mymember(string)", Kind = LogicalLocationKind.Member } }; var converter = new FxCopConverter(); Result result = converter.CreateResult(context); ValidateLogicalLocations(expectedLogicalLocations, converter.LogicalLocations); }
public void FxCopConverter_CreateIssue_FakeContext_NoModule_Member() { var context = TestHelper.CreateProjectContext(); context.RefineTarget(@"mybinary.dll"); context.RefineNamespace("mynamespace"); context.RefineType("mytype"); context.RefineMember("mymember(string)"); context.RefineMessage("CA0000", "VeryUsefulCheck", null, null, null, null); context.RefineIssue("hello!", null, null, null, null, null, null); var expectedLogicalLocation = "mynamespace.mytype.mymember(string)"; var expectedLocations = new[] { new Location { AnalysisTarget = new PhysicalLocation { Uri = new Uri("mybinary.dll", UriKind.RelativeOrAbsolute), }, FullyQualifiedLogicalName = expectedLogicalLocation } }; var expectedLogicalLocations = new Dictionary<string, LogicalLocation> { { "mynamespace", new LogicalLocation { ParentKey = null, Name = "mynamespace", Kind = LogicalLocationKind.Namespace } }, { "mynamespace.mytype", new LogicalLocation { ParentKey = "mynamespace", Name = "mytype", Kind = LogicalLocationKind.Type } }, { "mynamespace.mytype.mymember(string)", new LogicalLocation { ParentKey = "mynamespace.mytype", Name = "mymember(string)", Kind = LogicalLocationKind.Member } } }; var converter = new FxCopConverter(); Result result = converter.CreateResult(context); foreach (string key in expectedLogicalLocations.Keys) { expectedLogicalLocations[key].ValueEquals(converter.LogicalLocationsDictionary[key]).Should().BeTrue(); } converter.LogicalLocationsDictionary.Count.Should().Be(expectedLogicalLocations.Count); }
public void FxCopConverter_CreateResult_FakeContext_Resource() { var context = TestHelper.CreateProjectContext(); context.RefineTarget(@"mybinary.dll"); context.RefineModule("mybinary.dll"); context.RefineResource("myresource.resx"); context.RefineMessage("CA0000", "VeryUsefulCheck", null, null, null, null); context.RefineIssue("hello!", "test", null, null, @"source", "myfile.cs", 13); var expectedLogicalLocation = "myresource.resx"; var expectedLocations = new[] { new Location { AnalysisTarget = new PhysicalLocation { Uri = new Uri("mybinary.dll", UriKind.RelativeOrAbsolute), }, ResultFile = new PhysicalLocation { Uri = new Uri("source\\myfile.cs", UriKind.RelativeOrAbsolute), Region = new Region { StartLine = 13 } }, FullyQualifiedLogicalName = expectedLogicalLocation, } }; var expectedLogicalLocations = new Dictionary<string, LogicalLocation> { { "mybinary.dll", new LogicalLocation { ParentKey = null, Name = "mybinary.dll", Kind = LogicalLocationKind.Module } }, { "mybinary.dll!myresource.resx", new LogicalLocation { ParentKey = "mybinary.dll", Name = "myresource.resx",Kind = LogicalLocationKind.Resource } }, }; var converter = new FxCopConverter(); Result result = converter.CreateResult(context); foreach (string key in expectedLogicalLocations.Keys) { expectedLogicalLocations[key].ValueEquals(converter.LogicalLocationsDictionary[key]).Should().BeTrue(); } converter.LogicalLocationsDictionary.Count.Should().Be(expectedLogicalLocations.Count); }
public void FxCopConverter_CreateResult_FakeContext_NoModule_Resource() { var context = TestHelper.CreateProjectContext(); context.RefineTarget(@"mybinary.dll"); context.RefineResource("myresource.resx"); context.RefineMessage("CA0000", "VeryUsefulCheck", null, null, null, null); context.RefineIssue("hello!", "test", null, null, null, null, null); var converter = new FxCopConverter(); Result result = converter.CreateResult(context); result.Locations.First().FullyQualifiedLogicalName.Should().Be(@"myresource.resx"); }
public void FxCopConverter_CreateResult_FakeContext_Member() { var context = TestHelper.CreateProjectContext(); context.RefineTarget(@"mybinary.dll"); context.RefineModule("mybinary.dll"); context.RefineNamespace("mynamespace"); context.RefineType("mytype"); context.RefineMember("mymember(string)"); context.RefineMessage("CA0000", "VeryUsefulCheck", "1", "FakeCategory", "Breaking", "ExcludedInSource"); context.RefineIssue("hello!", "test", "uncertain", "error", @"source", "myfile.cs", 13); string expectedLogicalLocation = "mynamespace.mytype.mymember(string)"; var expectedResult = new Result { RuleId = "CA0000", Message = "hello!", ToolFingerprintContribution = "1#test", SuppressionStates = SuppressionStates.SuppressedInSource, Locations = new List<Location> { new Location { AnalysisTarget = new PhysicalLocation { Uri = new Uri("mybinary.dll", UriKind.RelativeOrAbsolute), }, ResultFile = new PhysicalLocation { Uri = new Uri("source\\myfile.cs", UriKind.RelativeOrAbsolute), Region = new Region { StartLine = 13 } }, FullyQualifiedLogicalName = expectedLogicalLocation, } } }; expectedResult.SetProperty("Level", "error"); expectedResult.SetProperty("Category", "FakeCategory"); expectedResult.SetProperty("FixCategory", "Breaking"); var expectedLogicalLocations = new Dictionary<string, LogicalLocation> { { "mybinary.dll", new LogicalLocation { ParentKey = null, Name = "mybinary.dll", Kind = LogicalLocationKind.Module } }, { "mybinary.dll!mynamespace", new LogicalLocation { ParentKey = "mybinary.dll", Name = "mynamespace", Kind = LogicalLocationKind.Namespace } }, { "mybinary.dll!mynamespace.mytype", new LogicalLocation { ParentKey = "mybinary.dll!mynamespace", Name = "mytype", Kind = LogicalLocationKind.Type } }, { "mybinary.dll!mynamespace.mytype.mymember(string)", new LogicalLocation { ParentKey = "mybinary.dll!mynamespace.mytype", Name = "mymember(string)", Kind = LogicalLocationKind.Member } } }; var converter = new FxCopConverter(); Result result = converter.CreateResult(context); foreach (string key in expectedLogicalLocations.Keys) { expectedLogicalLocations[key].ValueEquals(converter.LogicalLocationsDictionary[key]).Should().BeTrue(); } converter.LogicalLocationsDictionary.Count.Should().Be(expectedLogicalLocations.Count); }
public void FxCopConverter_CreateResult_FakeContext_Member() { var context = TestHelper.CreateProjectContext(); context.RefineTarget(@"mybinary.dll"); context.RefineModule("mybinary.dll"); context.RefineNamespace("mynamespace"); context.RefineType("mytype"); context.RefineMember("mymember(string)"); context.RefineMessage("CA0000", "VeryUsefulCheck", "1", "FakeCategory", "Breaking", "ExcludedInSource"); context.RefineIssue(null, "test", "uncertain", "error", @"source", "myfile.cs", 13); context.RefineItem("hello!"); string expectedLogicalLocation = "mynamespace.mytype.mymember(string)"; var expectedResult = new Result { RuleId = "CA0000", Message = new Message { Arguments = new List <string>(new string[] { "hello!" }) }, SuppressionStates = SuppressionStates.SuppressedInSource, PartialFingerprints = new Dictionary <string, string>(), AnalysisTarget = new FileLocation { Uri = new Uri("mybinary.dll", UriKind.RelativeOrAbsolute), }, Locations = new List <Location> { new Location { PhysicalLocation = new PhysicalLocation { FileLocation = new FileLocation { Uri = new Uri("source\\myfile.cs", UriKind.RelativeOrAbsolute) }, Region = new Region { StartLine = 13 } }, FullyQualifiedLogicalName = expectedLogicalLocation, } } }; expectedResult.PartialFingerprints.Add("UniqueId", "1#test"); expectedResult.SetProperty("Level", "error"); expectedResult.SetProperty("Category", "FakeCategory"); expectedResult.SetProperty("FixCategory", "Breaking"); var expectedLogicalLocations = new Dictionary <string, LogicalLocation> { { "mybinary.dll", new LogicalLocation { ParentKey = null, Kind = LogicalLocationKind.Module } }, { "mybinary.dll!mynamespace", new LogicalLocation { ParentKey = "mybinary.dll", Name = "mynamespace", Kind = LogicalLocationKind.Namespace } }, { "mybinary.dll!mynamespace.mytype", new LogicalLocation { ParentKey = "mybinary.dll!mynamespace", Name = "mytype", Kind = LogicalLocationKind.Type } }, { "mybinary.dll!mynamespace.mytype.mymember(string)", new LogicalLocation { ParentKey = "mybinary.dll!mynamespace.mytype", Name = "mymember(string)", Kind = LogicalLocationKind.Member } } }; var converter = new FxCopConverter(); Result result = converter.CreateResult(context); foreach (string key in expectedLogicalLocations.Keys) { expectedLogicalLocations[key].ValueEquals(converter.LogicalLocationsDictionary[key]).Should().BeTrue(); } converter.LogicalLocationsDictionary.Count.Should().Be(expectedLogicalLocations.Count); }
public void FxCopConverter_CreateResult_FakeContext_Member() { var context = TestHelper.CreateProjectContext(); context.RefineTarget(@"mybinary.dll"); context.RefineModule("mybinary.dll"); context.RefineNamespace("mynamespace"); context.RefineType("mytype"); context.RefineMember("mymember(string)"); context.RefineMessage("CA0000", "VeryUsefulCheck", "1", "FakeCategory", "Breaking"); context.RefineIssue("hello!", "test", "uncertain", "error", @"source", "myfile.cs", 13); string expectedLogicalLocation = "mynamespace.mytype.mymember(string)"; var expectedResult = new Result { RuleId = "CA0000", Message = "hello!", ToolFingerprint = "1#test", Locations = new HashSet <Location> { new Location { AnalysisTarget = new PhysicalLocation { Uri = new Uri("mybinary.dll", UriKind.RelativeOrAbsolute), }, ResultFile = new PhysicalLocation { Uri = new Uri("source\\myfile.cs", UriKind.RelativeOrAbsolute), Region = new Region { StartLine = 13 } }, FullyQualifiedLogicalName = expectedLogicalLocation, } }, Properties = new Dictionary <string, string> { { "Level", "error" }, { "Category", "FakeCategory" }, { "FixCategory", "Breaking" } } }; var expectedLogicalLocationComponents = new[] { new LogicalLocationComponent { Name = "mybinary.dll", Kind = LogicalLocationKind.Module }, new LogicalLocationComponent { Name = "mynamespace", Kind = LogicalLocationKind.Namespace }, new LogicalLocationComponent { Name = "mytype", Kind = LogicalLocationKind.Type }, new LogicalLocationComponent { Name = "mymember(string)", Kind = LogicalLocationKind.Member } }; var converter = new FxCopConverter(); Result result = converter.CreateResult(context); result.Should().Be(expectedResult); converter.LogicalLocationsDictionary.Keys.Should().ContainSingle(expectedLogicalLocation); var actualLogicalLocationComponents = converter.LogicalLocationsDictionary[expectedLogicalLocation]; actualLogicalLocationComponents.Should().Equal(expectedLogicalLocationComponents); }