/// <summary>
        /// Activates a policy failure.
        /// </summary>
        /// <param name="failure">The failure to activate.</param>
        public override void Activate(PolicyFailure failure)
        {
            SourceAnalysisPolicyFailure policyFailure = failure as SourceAnalysisPolicyFailure;

            if (policyFailure != null)
            {
                // Create dialog to show the violations
                using (DisplayViolationsDialog dialog = new DisplayViolationsDialog())
                {
                    // Set the violations in the dialog.
                    dialog.Violations = policyFailure.Violations;

                    // Show dialog
                    dialog.ShowDialog();

                    // Check if there is a selected violation
                    if (dialog.SelectedViolation != null)
                    {
                        // There is a selected violation so move to it.
                        ViolationTask.MoveToViolation(dte, dialog.SelectedViolation);
                    }
                }
            }

            base.Activate(failure);
        }
Ejemplo n.º 2
0
        public void MyTestInitialize()
        {
            try
            {
                // Creating a package will set the factory service provider.
                this.package = new StyleCopVSPackage();

                this.mockServiceProvider = new Mock <IServiceProvider>();

                // Creates a dummy violation (In visual studio the violation is displayed in Error List panel)
                this.violation = CreateDummyViolationInfo();

                Assert.IsNotNull(this.package, "this.package is null");

                PrivateObject actual = new PrivateObject(this.package, new PrivateType(typeof(StyleCopVSPackage)));
                StyleCopCore  core   = (StyleCopCore)actual.GetFieldOrProperty("Core");

                Assert.IsNotNull(core, "core is null");

                core.DisplayUI          = false;
                this.taskUnderTest      = new ViolationTask(this.package, this.violation, null);
                this.taskUnderTestShell = this.taskUnderTest;
            }
            catch (Exception ex)
            {
                // Use try catch to test a workaround on CI build (AppVeyor)
                Console.WriteLine(ex.Message);
            }
        }
Ejemplo n.º 3
0
        public void MyTestInitialize()
        {
            // Creating a package will set the factory service provider.
            this.package = new StyleCopVSPackage();

            this.mockServiceProvider = new Mock <IServiceProvider>(MockBehavior.Strict);
            this.violation           = CreateDummyViolationInfo();

            this.package.Core.DisplayUI = false;
            this.taskUnderTest          = new ViolationTask(this.package, this.violation, null);
            this.taskUnderTestShell     = taskUnderTest;
        }
Ejemplo n.º 4
0
 public void MyTestCleanup()
 {
     this.taskUnderTest      = null;
     this.taskUnderTestShell = null;
     this.taskUnderTest      = null;
 }