/// <summary>
        /// Initializes a new instance of the <see cref="IssuesGridSettingsDialog"/> class.
        /// </summary>
        /// <param name="dataModelIn">
        /// The data model in.
        /// </param>
        public IssuesGridSettingsDialog(ExtensionDataModel dataModelIn)
        {
            this.InitializeComponent();

            this.DataContext = null;
            this.DataContext = dataModelIn;
        }
 public void CoverageInEditorSetAndGetTest()
 {
     var data = new ExtensionDataModel(this.service, this.vshelper, null);
     var sourceCoverage = new SourceCoverage();
     data.CoverageInEditor = sourceCoverage;
     Assert.AreEqual(sourceCoverage, data.CoverageInEditor);
 }
        /// <summary>
        /// The update data context.
        /// </summary>
        /// <param name="dataModelIn">
        /// The data model in.
        /// </param>
        public void UpdateDataContext(ExtensionDataModel dataModelIn)
        {
            // bind data with view model
            this.dataModel = dataModelIn;
            this.DataContext = null;
            this.DataContext = dataModelIn;

            this.BindCommandsInWindow(dataModelIn);
        }
 public void DisableCoverageInEditor()
 {
     var data = new ExtensionDataModel(this.service, this.vshelper, null);
     var sourceCoverage = new SourceCoverage();
     data.CoverageInEditor = sourceCoverage;
     data.EnableCoverageInEditor = false;
     Assert.IsFalse(data.EnableCoverageInEditor);
     Assert.AreNotEqual(sourceCoverage, data.CoverageInEditor);
     Assert.AreEqual(0, data.CoverageInEditor.BranchHits.Count);
     Assert.AreEqual(0, data.CoverageInEditor.LinesHits.Count);
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="IssueWindow"/> class.
        /// </summary>
        /// <param name="dataModelIn">
        /// The data Model In.
        /// </param>
        public IssueWindow(ExtensionDataModel dataModelIn)
        {
            this.InitializeComponent();

            // bind data with view model
            this.dataModel = dataModelIn;
            this.DataContext = null;
            this.DataContext = dataModelIn;

            this.BindCommandsInWindow(dataModelIn);
        }
        public void VerifyResetVisibilitiesWhenStatusIsNotDefined()
        {
            var data = new ExtensionDataModel(this.service, this.vshelper, null)
            {
                UpdateSelectedIssuesInView =
                    new List<Issue>
                                       {
                                           new Issue { Status = null }
                                       }
            };

            Assert.AreEqual(Visibility.Hidden, data.IsReopenVisible);
            Assert.AreEqual(Visibility.Hidden, data.IsResolveVisible);
            Assert.AreEqual(Visibility.Hidden, data.IsFalsePositiveVisible);
            Assert.AreEqual(Visibility.Hidden, data.IsCommentingVisible);
            Assert.AreEqual(Visibility.Hidden, data.UserInputTextBoxVisibility);
            Assert.AreEqual(Visibility.Hidden, data.IsConfirmVisible);
            Assert.AreEqual(Visibility.Hidden, data.IsUnconfirmVisible);
            Assert.AreEqual(Visibility.Hidden, data.IsAssignVisible);
            Assert.AreEqual(Visibility.Hidden, data.IsOpenExternallyVisible);
            var lentthCrl = data.UserControlsHeight;
            var lenthTextCrl = data.UserTextControlsHeight;
            Assert.AreEqual(0.0, lenthTextCrl.Value);
            Assert.AreEqual(0.0, lentthCrl.Value);
            Assert.AreEqual(1, data.UpdateSelectedIssuesInView.Count);
        }
        public void UpdateCoverageDataForResourceEmtpyDataTest()
        {
            var element = new Resource { Date = new DateTime(2000, 1, 1) };
            var source = new SourceCoverage();

            this.service.Expect(
                mp => mp.GetResourcesData(Arg<ConnectionConfiguration>.Is.Anything, Arg<string>.Is.Equal("resource")))
                .Return(new List<Resource> { element })
                .Repeat.Once();
            this.service.Expect(
                mp => mp.GetCoverageInResource(Arg<ConnectionConfiguration>.Is.Anything, Arg<string>.Is.Equal("resource")))
                .Return(source);

            var data = new ExtensionDataModel(this.service, this.vshelper, null);
            Assert.AreEqual(source, data.UpdateCoverageDataForResource("resource", false));
        }
        public void UpdateSourceDataForResourceWithNewDateDataTest()
        {
            var element = new Resource();
            var newResource = new Resource { Date = DateTime.Now };
            var source1 = new Source();
            var source2 = new Source();

            this.service.Expect(
                mp => mp.GetResourcesData(Arg<ConnectionConfiguration>.Is.Anything, Arg<string>.Is.Equal("resource")))
                .Return(new List<Resource> { element })
                .Repeat.Once();
            this.service.Expect(
                mp => mp.GetResourcesData(Arg<ConnectionConfiguration>.Is.Anything, Arg<string>.Is.Equal("resource")))
                .Return(new List<Resource> { newResource });

            this.service.Expect(
                mp => mp.GetSourceForFileResource(Arg<ConnectionConfiguration>.Is.Anything, Arg<string>.Is.Equal("resource")))
                .Return(source1)
                .Repeat.Once();
            this.service.Expect(
                mp => mp.GetSourceForFileResource(Arg<ConnectionConfiguration>.Is.Anything, Arg<string>.Is.Equal("resource")))
                .Return(source2);

            var data = new ExtensionDataModel(this.service, this.vshelper, null);
            Assert.AreEqual(source1, data.UpdateSourceDataForResource("resource", false));
            Assert.AreEqual(source2, data.UpdateSourceDataForResource("resource", false));
        }
        public void UpdateIssueDataForResourceWithNewDateDataTestWithCache()
        {
            var element = new Resource();
            var newResource = new Resource { Date = DateTime.Now };
            var newResource1 = new Resource { Date = DateTime.Now };

            this.service.Expect(
                mp => mp.GetResourcesData(Arg<ConnectionConfiguration>.Is.Anything, Arg<string>.Is.Equal("resource")))
                .Return(new List<Resource> { element })
                .Repeat.Once();
            this.service.Expect(
                mp => mp.GetResourcesData(Arg<ConnectionConfiguration>.Is.Anything, Arg<string>.Is.Equal("resource")))
                .Return(new List<Resource> { newResource });
            this.service.Expect(
                mp => mp.GetResourcesData(Arg<ConnectionConfiguration>.Is.Anything, Arg<string>.Is.Equal("resource1")))
                .Return(new List<Resource> { newResource1 });

            this.service.Expect(
                mp => mp.GetIssuesInResource(Arg<ConnectionConfiguration>.Is.Anything, Arg<string>.Is.Equal("resource"), Arg<bool>.Is.Anything))
                .Return(new List<Issue> { new Issue() })
                .Repeat.Once();
            this.service.Expect(
                mp => mp.GetIssuesInResource(Arg<ConnectionConfiguration>.Is.Anything, Arg<string>.Is.Equal("resource"), Arg<bool>.Is.Anything))
                .Return(new List<Issue> { new Issue(), new Issue() });
            this.service.Expect(
                mp => mp.GetIssuesInResource(Arg<ConnectionConfiguration>.Is.Anything, Arg<string>.Is.Equal("resource1"), Arg<bool>.Is.Anything))
                .Return(new List<Issue> { new Issue() });

            var data = new ExtensionDataModel(this.service, this.vshelper, null);
            Assert.AreEqual(1, data.UpdateIssueDataForResource("resource").Count);
            Assert.AreEqual(2, data.UpdateIssueDataForResource("resource").Count);
            Assert.AreEqual(2, data.UpdateIssueDataForResource("resource").Count);
            Assert.AreEqual(1, data.UpdateIssueDataForResource("resource1").Count);
            Assert.AreEqual("resource1", data.SelectedCachedElement);
            data.SelectedCachedElement = "resource1";
            Assert.AreEqual(1, data.Issues.Count);
            data.SelectedCachedElement = "resource";
            Assert.AreEqual(2, data.Issues.Count);
            Assert.AreEqual("resource", data.SelectedCachedElement);
        }
 public void TestUpdateModelUpdateData()
 {
     var model = new ExtensionDataModel();
     model.ExtensionDataModelUpdate(this.service, this.vshelper, new Resource());
     Assert.AreEqual(0, model.Issues.Count);
     Assert.AreEqual(this.service, model.RestService);
     Assert.AreEqual(this.vshelper, model.Vsenvironmenthelper);
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="GetIssuesCommand"/> class.
 /// </summary>
 /// <param name="model">
 /// The model.
 /// </param>
 /// <param name="service">
 /// The service.
 /// </param>
 public GetIssuesCommand(ExtensionDataModel model, ISonarRestService service)
 {
     this.model = model;
     this.service = service;
 }
 /// <summary>
 /// The update model.
 /// </summary>
 /// <param name="myModel">
 /// The my model.
 /// </param>
 public void UpdateModel(ExtensionDataModel myModel)
 {
     this.windowToUse.UpdateDataContext(myModel);
 }
 /// <summary>
 /// The bind commands in window.
 /// </summary>
 /// <param name="dataModelIn">
 /// The data model in.
 /// </param>
 private void BindCommandsInWindow(ExtensionDataModel dataModelIn)
 {
     // bind commands
     this.ConfPluginsOptions.DataContext = new ExtensionMenuCommand(dataModelIn);
     this.ConfIssuesWindow.DataContext = new ExtensionMenuCommand(dataModelIn);
 }
        /// <summary>
        /// The test window.
        /// </summary>
        //[Test]
        public void TestWindow()
        {
            var mocks = new MockRepository();
            var mockHttpReq = mocks.Stub<IHttpSonarConnector>();
            var mockVsHelpers = mocks.Stub<IVsEnvironmentHelper>();
            var config = new ConnectionConfiguration("serveraddr", "login", "password");

            // set expectations
            using (mocks.Record())
            {
                SetupResult.For(mockHttpReq.HttpSonarGetRequest(config, "/api/issues/search?components=resource")).Return(File.ReadAllText("TestData/issuessearchbycomponent.txt"));
                SetupResult.For(mockHttpReq.HttpSonarGetRequest(config, "/api/users/search")).Return(File.ReadAllText("TestData/userList.txt"));
            }

            ISonarRestService service = new SonarRestService(mockHttpReq);
            var issues = service.GetIssuesInResource(config, "resource", false);
            var associatedProject = new Resource { Key = "core:Common" };

            this.model = new ExtensionDataModel(service, mockVsHelpers, associatedProject) { Issues = issues };
            var t = new Thread(new ThreadStart(this.Threadprc));
            t.SetApartmentState(ApartmentState.STA);
            t.Start();
            t.Join();
        }
        public void TesRestOfProperties()
        {
            var issue = new Issue();
            var connector = new SonarRestService(new JsonSonarConnector());
            var projectAsso = new Resource { Key = "proj" };
            var model = new ExtensionDataModel(this.service, this.vshelper, null)
            {
                AssociatedProjectKey = "proj",
                CommentData = "comment",
                SelectedIssue = issue,
                SonarInfo = "ver",
                SelectedUser = new User { Login = "******" },
                DiagnosticMessage = "MessageData",
                IssuesInViewLocked = false,
                DisableEditorTags = false,
                LastReferenceSource = "source",
                RestService = connector,
                ServerAnalysis = ExtensionDataModel.AnalysesType.Off,
                AssociatedProject = projectAsso,
            };

            Assert.AreEqual("Selected Project: proj", model.AssociatedProjectKey);
            Assert.AreEqual(issue, model.SelectedIssue);
            Assert.AreEqual("comment", model.CommentData);
            Assert.AreEqual("login", model.SelectedUser.Login);
            Assert.AreEqual("ver", model.SonarInfo);
            Assert.AreEqual("MessageData", model.DiagnosticMessage);
            Assert.IsFalse(model.IssuesInViewLocked);
            Assert.IsFalse(model.DisableEditorTags);
            Assert.AreEqual("source", model.LastReferenceSource);
            Assert.AreEqual(connector, model.RestService);
            Assert.AreEqual(ExtensionDataModel.AnalysesType.Off, model.ServerAnalysis);
            Assert.AreEqual(projectAsso, model.AssociatedProject);
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="ConfigureIssuesWindowCommand"/> class. 
 /// Initializes a new instance of the <see cref="SelectAProjectCommand"/> class.
 /// </summary>
 /// <param name="model">
 /// The model.
 /// </param>
 public ConfigureIssuesWindowCommand(ExtensionDataModel model)
 {
     this.model = model;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="FalsePositiveOnIssueCommand"/> class.
 /// </summary>
 /// <param name="model">
 /// The model.
 /// </param>
 /// <param name="service">
 /// The service.
 /// </param>
 public FalsePositiveOnIssueCommand(ExtensionDataModel model, ISonarRestService service)
 {
     this.model = model;
     this.service = service;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="SonarTagDisplayViolationsAction"/> class.
 /// </summary>
 /// <param name="issue">
 /// The issue.
 /// </param>
 /// <param name="model">
 /// The model.
 /// </param>
 /// <param name="enabledIn">
 /// The enabled In.
 /// </param>
 public SonarTagDisplayViolationsAction(Issue issue, ExtensionDataModel model, bool enabledIn = true)
 {
     this.model = model;
     this.issue = issue;
     this.enabled = enabledIn;
 }
        public void VerifyResolvedTest()
        {
            var data = new ExtensionDataModel(this.service, this.vshelper, null)
            {
                UpdateSelectedIssuesInView =
                    new List<Issue>
                                       {
                                           new Issue { Status = "RESOLVED" }
                                       }
            };

            Assert.AreEqual(Visibility.Visible, data.IsReopenVisible);
            Assert.AreEqual(Visibility.Hidden, data.IsResolveVisible);
            Assert.AreEqual(Visibility.Hidden, data.IsFalsePositiveVisible);
            Assert.AreEqual(Visibility.Visible, data.IsCommentingVisible);
            Assert.AreEqual(Visibility.Hidden, data.IsConfirmVisible);
            Assert.AreEqual(Visibility.Hidden, data.IsUnconfirmVisible);
            Assert.AreEqual(Visibility.Hidden, data.IsAssignVisible);
            Assert.AreEqual(Visibility.Visible, data.IsOpenExternallyVisible);
            var lentthCrl = data.UserControlsHeight;
            var lenthTextCrl = data.UserTextControlsHeight;
            Assert.AreEqual(50.0, lenthTextCrl.Value);
            Assert.AreEqual(25.0, lentthCrl.Value);
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="SelectAProjectCommand"/> class.
 /// </summary>
 /// <param name="model">
 /// The model.
 /// </param>
 public SelectAProjectCommand(ExtensionDataModel model)
 {
     this.model = model;
 }
        /// <summary>
        /// The update model in tool window.
        /// </summary>
        /// <param name="modelToUse">
        /// The model to use.
        /// </param>
        private void UpdateModelInToolWindow(ExtensionDataModel modelToUse)
        {
            // init basic model without project association
            ToolWindowPane window = this.FindToolWindow(typeof(IssuesToolWindow), 0, true) as IssuesToolWindow;

            if (null == window || modelToUse == null)
            {
                return;
            }

            var win = window as IssuesToolWindow;
            modelToUse.ExtensionDataModelUpdate(new SonarRestService(new JsonSonarConnector()), new VsPropertiesHelper(this.dte2), null);
            win.UpdateModel(modelToUse);
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="ExtensionMenuCommand"/> class.
 /// </summary>
 /// <param name="model">
 /// The model.
 /// </param>
 public ExtensionMenuCommand(ExtensionDataModel model)
 {
     this.model = model;
 }
 public void EnableCoverageInEditor()
 {
     var data = new ExtensionDataModel(this.service, this.vshelper, null);
     var sourceCoverage = new SourceCoverage();
     var source = new Source { Lines = new List<Line> { new Line { Id = 1, Val = "#include bal" }, new Line { Id = 2, Val = "#include bals" } } };
     var element = new Resource { Date = new DateTime(2000, 1, 1) };
     this.service.Expect(
         mp => mp.GetResourcesData(Arg<ConnectionConfiguration>.Is.Anything, Arg<string>.Is.Equal("resource")))
         .Return(new List<Resource> { element })
         .Repeat.Twice();
     this.service.Expect(
         mp => mp.GetSourceForFileResource(Arg<ConnectionConfiguration>.Is.Anything, Arg<string>.Is.Equal("resource")))
         .Return(source);
     this.service.Expect(
         mp => mp.GetCoverageInResource(Arg<ConnectionConfiguration>.Is.Anything, Arg<string>.Is.Equal("resource")))
         .Return(sourceCoverage);
     element.Key = "resource";
     data.ResourceInEditor = element;
     data.EnableCoverageInEditor = true;
     Assert.IsTrue(data.EnableCoverageInEditor);
     Assert.AreEqual(sourceCoverage, data.CoverageInEditor);
     Assert.AreEqual(element, data.ResourceInEditor);
     Assert.AreEqual(0, data.CoverageInEditor.BranchHits.Count);
     Assert.AreEqual(0, data.CoverageInEditor.LinesHits.Count);
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="AssignOnIssueCommand"/> class. 
 /// </summary>
 /// <param name="model">
 /// The model.
 /// </param>
 /// <param name="service">
 /// The service.
 /// </param>
 public AssignOnIssueCommand(ExtensionDataModel model, ISonarRestService service)
 {
     this.model = model;
     this.service = service;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="OpenInSonarCommand"/> class.
 /// </summary>
 /// <param name="model">
 /// The model.
 /// </param>
 /// <param name="restService">
 /// The rest service.
 /// </param>
 /// <param name="vsenvironmenthelper">
 /// The vsenvironmenthelper.
 /// </param>
 public OpenInSonarCommand(ExtensionDataModel model, ISonarRestService restService, IVsEnvironmentHelper vsenvironmenthelper)
 {
     this.model = model;
     this.vsenvironmenthelper = vsenvironmenthelper;
     this.restService = restService;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="ClearCacheCommand"/> class.
 /// </summary>
 /// <param name="model">
 /// The model.
 /// </param>
 public ClearCacheCommand(ExtensionDataModel model)
 {
     this.model = model;
 }
        public void VerifyConfirmStatus()
        {
            var data = new ExtensionDataModel(this.service, this.vshelper, null)
            {
                UpdateSelectedIssuesInView =
                    new List<Issue>
                                       {
                                           new Issue { Status = "CONFIRMED" }
                                       }
            };

            Assert.AreEqual(Visibility.Hidden, data.IsReopenVisible);
            Assert.AreEqual(Visibility.Visible, data.IsResolveVisible);
            Assert.AreEqual(Visibility.Visible, data.IsFalsePositiveVisible);
            Assert.AreEqual(Visibility.Visible, data.IsCommentingVisible);
            Assert.AreEqual(Visibility.Hidden, data.IsConfirmVisible);
            Assert.AreEqual(Visibility.Visible, data.IsUnconfirmVisible);
            Assert.AreEqual(Visibility.Visible, data.IsAssignVisible);
            Assert.AreEqual(Visibility.Visible, data.IsOpenExternallyVisible);
        }
        public void UpdateCoverageDataForResourceWithNewDateDataTest()
        {
            var element = new Resource();
            var newResource = new Resource { Date = DateTime.Now };
            var source1 = new SourceCoverage();
            source1.SetLineCoverageData("1=0;2=3;2=3");
            source1.SetBranchCoverageData("1=0;2=3;2=3", "1=0;2=3;2=3");
            var source2 = new SourceCoverage();

            this.service.Expect(
                mp => mp.GetResourcesData(Arg<ConnectionConfiguration>.Is.Anything, Arg<string>.Is.Equal("resource")))
                .Return(new List<Resource> { element })
                .Repeat.Once();
            this.service.Expect(
                mp => mp.GetResourcesData(Arg<ConnectionConfiguration>.Is.Anything, Arg<string>.Is.Equal("resource")))
                .Return(new List<Resource> { newResource });

            this.service.Expect(
                mp => mp.GetCoverageInResource(Arg<ConnectionConfiguration>.Is.Anything, Arg<string>.Is.Equal("resource")))
                .Return(source1)
                .Repeat.Once();
            this.service.Expect(
                mp => mp.GetCoverageInResource(Arg<ConnectionConfiguration>.Is.Anything, Arg<string>.Is.Equal("resource")))
                .Return(source2);

            var data = new ExtensionDataModel(this.service, this.vshelper, null);
            data.EnableCoverageInEditor = true;
            Assert.AreEqual(source1, data.UpdateCoverageDataForResource("resource", false));
            Assert.AreEqual(source2, data.UpdateCoverageDataForResource("resource", false));
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="AssociateCommand"/> class.
 /// </summary>
 /// <param name="model">
 /// The model.
 /// </param>
 /// <param name="vsenvironmenthelper">
 /// The vsenvironmenthelper.
 /// </param>
 public AssociateCommand(ExtensionDataModel model, IVsEnvironmentHelper vsenvironmenthelper)
 {
     this.model = model;
     this.vsenvironmenthelper = vsenvironmenthelper;
 }
 public void TestSetUserList()
 {
     var model = new ExtensionDataModel(this.service, this.vshelper, null)
     {
         UsersList = new System.Collections.Generic.List<User>
                                 {
                                    new User()
                                 }
     };
     Assert.AreEqual(1, model.UsersList.Count);
 }