public void SarifErrorListItem_WhenFixIsConfinedToOneFile_IsFixable()
        {
            var result = new Result
            {
                Fixes = new List <Fix>
                {
                    new Fix
                    {
                        ArtifactChanges = new List <ArtifactChange>
                        {
                            new ArtifactChange
                            {
                                ArtifactLocation = new ArtifactLocation
                                {
                                    Uri = new Uri(FileName, UriKind.Relative),
                                },
                                Replacements = new List <Replacement>
                                {
                                    new Replacement
                                    {
                                        DeletedRegion = new Region
                                        {
                                            CharOffset = 52,
                                            CharLength = 5,
                                        },
                                    },
                                },
                            },
                            new ArtifactChange
                            {
                                ArtifactLocation = new ArtifactLocation
                                {
                                    Uri = new Uri(FileName, UriKind.Relative),
                                },
                                Replacements = new List <Replacement>
                                {
                                    new Replacement
                                    {
                                        DeletedRegion = new Region
                                        {
                                            CharOffset = 52,
                                            CharLength = 5,
                                        },
                                    },
                                },
                            },
                        },
                    },
                },
            };

            SarifErrorListItem item = TestUtilities.MakeErrorListItem(result);

            CodeAnalysisResultManager.Instance.RunIndexToRunDataCache.Add(item.RunIndex, new RunDataCache());
            item.Fixes.Should().BeEmpty();
            item.PopulateFixModelsIfNot();
            item.Fixes.Should().NotBeEmpty();
            item.IsFixable().Should().BeTrue();
        }
예제 #2
0
        public void SarifErrorListItem_WhenThereAreNoFixes_IsNotFixable()
        {
            var result = new Result();

            SarifErrorListItem item = MakeErrorListItem(result);

            item.IsFixable().Should().BeFalse();
        }
예제 #3
0
        public void SarifErrorListItem_WhenFixSpansMultipleFiles_IsNotFixable()
        {
            var result = new Result
            {
                Fixes = new List <Fix>
                {
                    new Fix
                    {
                        ArtifactChanges = new List <ArtifactChange>
                        {
                            new ArtifactChange
                            {
                                ArtifactLocation = new ArtifactLocation
                                {
                                    Uri = new Uri(FileName, UriKind.Relative),
                                },
                                Replacements = new List <Replacement>
                                {
                                    new Replacement
                                    {
                                        DeletedRegion = new Region
                                        {
                                            CharOffset = 52,
                                            CharLength = 5,
                                        },
                                    },
                                },
                            },
                            new ArtifactChange
                            {
                                ArtifactLocation = new ArtifactLocation
                                {
                                    Uri = new Uri("SomeOther" + FileName, UriKind.Relative),
                                },
                                Replacements = new List <Replacement>
                                {
                                    new Replacement
                                    {
                                        DeletedRegion = new Region
                                        {
                                            CharOffset = 52,
                                            CharLength = 5,
                                        },
                                    },
                                },
                            },
                        },
                    },
                },
            };

            SarifErrorListItem item = MakeErrorListItem(result);

            item.IsFixable().Should().BeFalse();
        }
예제 #4
0
        public void SarifErrorListItem_WhenFixIsConfinedToOneFile_IsFixable()
        {
            var result = new Result
            {
                Fixes = new List <Fix>
                {
                    new Fix
                    {
                        ArtifactChanges = new List <ArtifactChange>
                        {
                            new ArtifactChange
                            {
                                ArtifactLocation = new ArtifactLocation
                                {
                                    Uri = new Uri(FileName, UriKind.Relative),
                                },
                                Replacements = new List <Replacement>
                                {
                                    new Replacement
                                    {
                                        DeletedRegion = new Region
                                        {
                                            CharOffset = 52,
                                            CharLength = 5,
                                        },
                                    },
                                },
                            },
                            new ArtifactChange
                            {
                                ArtifactLocation = new ArtifactLocation
                                {
                                    Uri = new Uri(FileName, UriKind.Relative),
                                },
                                Replacements = new List <Replacement>
                                {
                                    new Replacement
                                    {
                                        DeletedRegion = new Region
                                        {
                                            CharOffset = 52,
                                            CharLength = 5,
                                        },
                                    },
                                },
                            },
                        },
                    },
                },
            };

            SarifErrorListItem item = MakeErrorListItem(result);

            item.IsFixable().Should().BeTrue();
        }