public void FxCopConverter_CreateResult_FakeContext_Resource() { FxCopLogReader.Context 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 FxCopLogReader_Context_RefineModule() { FxCopLogReader.Context context = TestHelper.CreateProjectContext(); context.RefineModule("mybinary.dll"); Assert.Equal("mybinary.dll", context.Module); }
public void FxCopLogReader_Context_RefineProjectToMemberIssue() { FxCopLogReader.Context 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", "MyCategory", "Breaking", "Excluded"); context.RefineIssue("hello!", "test", "25", "error", "source", "myfile.cs", 13); Assert.Equal("mybinary.dll", context.Target); Assert.Equal("mybinary.dll", context.Module); Assert.Equal("mynamespace", context.Namespace); Assert.Equal("mytype", context.Type); Assert.Equal("mymember(string)", context.Member); Assert.Equal("CA0000", context.CheckId); Assert.Equal("1", context.MessageId); Assert.Equal("MyCategory", context.Category); Assert.Equal("VeryUsefulCheck", context.Typename); Assert.Equal("Breaking", context.FixCategory); Assert.Equal("hello!", context.Message); Assert.Equal("test", context.ResolutionName); Assert.Equal("25", context.Certainty); Assert.Equal("error", context.Level); Assert.Equal("source", context.Path); Assert.Equal("myfile.cs", context.File); Assert.Equal("Excluded", context.Status); Assert.Equal(13, context.Line.Value); context.ClearTarget(); Assert.Null(context.Target); Assert.Null(context.Module); Assert.Null(context.Namespace); Assert.Null(context.Type); Assert.Null(context.Member); Assert.Null(context.Message); Assert.Null(context.ResolutionName); }
public void FxCopConverter_CreateResult_FakeContext_Member() { FxCopLogReader.Context 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); }