예제 #1
0
            public void CoverageInEditorSetAndGetTest()
            {
                var data           = new ExtensionDataModel(this.service, this.vshelper, null, null);
                var sourceCoverage = new Dictionary <int, CoverageElement>();

                Assert.AreEqual(sourceCoverage, data.GetCoverageInEditor(string.Empty));
            }
예제 #2
0
        public void UpdateCoverageDataForResourceWithNewDateDataTest()
        {
            var newResource = new Resource {
                Date = DateTime.Now, Key = "resource"
            };
            var source1 = new SourceCoverage();

            source1.SetLineCoverageData("1=0;2=3;3=3");
            source1.SetBranchCoverageData("1=0;2=3;3=3", "1=0;2=3;3=3");

            this.service.Expect(
                mp => mp.GetResourcesData(Arg <ISonarConfiguration> .Is.Anything, Arg <string> .Is.Anything))
            .Return(new List <Resource> {
                newResource
            });

            this.service.Expect(
                mp => mp.GetSourceForFileResource(Arg <ISonarConfiguration> .Is.Anything, Arg <string> .Is.Anything))
            .Return(new Source {
                Lines = new[] { "line1", "line2", "line3", "line4" }
            })
            .Repeat.Once();

            this.service.Expect(
                mp => mp.GetIssuesInResource(Arg <ISonarConfiguration> .Is.Anything, Arg <string> .Is.Anything))
            .Return(new List <Issue>())
            .Repeat.Once();

            this.service.Expect(
                mp => mp.GetCoverageInResource(Arg <ISonarConfiguration> .Is.Anything, Arg <string> .Is.Anything))
            .Return(source1)
            .Repeat.Once();

            this.analysisPlugin.Expect(
                mp => mp.GetResourceKey(Arg <VsProjectItem> .Is.Anything, Arg <string> .Is.Anything, Arg <bool> .Is.Anything))
            .Return("resource");

            var data = new ExtensionDataModel(this.service, this.vshelper, null, null);

            data.AssociatedProject = new Resource {
                Key = "sonar.com:common"
            };
            data.CoverageInEditorEnabled = true;

            var localAnalyser = this.mocks.Stub <ISonarLocalAnalyser>();

            data.LocalAnalyserModule = localAnalyser;

            using (this.mocks.Record())
            {
                SetupResult.For(localAnalyser.GetResourceKey(Arg <VsProjectItem> .Is.Anything, Arg <Resource> .Is.Anything, Arg <ISonarConfiguration> .Is.Anything, Arg <bool> .Is.Equal(true))).Return("Key1");
                SetupResult.For(localAnalyser.GetResourceKey(Arg <VsProjectItem> .Is.Anything, Arg <Resource> .Is.Anything, Arg <ISonarConfiguration> .Is.Anything, Arg <bool> .Is.Equal(false))).Return("Key2");
            }

            data.RefreshDataForResource("resource");
            var data1 = data.GetCoverageInEditor("ghfggfgf\r\nghfggfgf\r\nghfggfgf\r\nghfggfgf\r\n");

            Assert.IsNotNull(data1);
        }
 public void DisableCoverageInEditor()
 {
     var data = new ExtensionDataModel(this.service, this.vshelper, null, null);
     var sourceCoverage = new SourceCoverage();
     data.CoverageInEditorEnabled = false;
     Assert.IsFalse(data.CoverageInEditorEnabled);
     Assert.AreNotEqual(sourceCoverage, data.GetCoverageInEditor(string.Empty));
 }
예제 #4
0
            public void DisableCoverageInEditor()
            {
                var data           = new ExtensionDataModel(this.service, this.vshelper, null, null);
                var sourceCoverage = new SourceCoverage();

                data.CoverageInEditorEnabled = false;
                Assert.IsFalse(data.CoverageInEditorEnabled);
                Assert.AreNotEqual(sourceCoverage, data.GetCoverageInEditor(string.Empty));
            }
 public void CoverageInEditorSetAndGetTest()
 {
     var data = new ExtensionDataModel(this.service, this.vshelper, null, null);
     var sourceCoverage = new Dictionary<int, CoverageElement>();
     Assert.AreEqual(sourceCoverage, data.GetCoverageInEditor(string.Empty));
 }