SonarLint.VisualStudio.Progress.Controller.DeterminateStepProgressNotifier.IncrementProgress C# (CSharp) Method

IncrementProgress() public method

Advances the progress by an increment. The progress needs to remain in valid range for this to succeed.
public IncrementProgress ( int increment = 1 ) : void
increment int 1 by default
return void
        public void IncrementProgress(int increment = 1)
        {
            if (increment < 1)
            {
                throw new ArgumentOutOfRangeException(nameof(increment));
            }

            if (this.currentValue + increment > this.maxNumberOfIncrements)
            {
                throw new ArgumentOutOfRangeException(nameof(increment), this.currentValue + increment, string.Format(CultureInfo.CurrentCulture, ControllerResources.InclusiveRangeExpectedExceptionMessage, 1, this.maxNumberOfIncrements));
            }

            this.currentValue += increment;
        }

Usage Example

        public void DeterminateStepProgressNotifier_IncrementProgress_ArgChecks()
        {
            // Setup
            var testSubject = new DeterminateStepProgressNotifier(new ConfigurableProgressController(null), 11);

            Exceptions.Expect<ArgumentOutOfRangeException>(() => testSubject.IncrementProgress(0));
            Exceptions.Expect<ArgumentOutOfRangeException>(() => testSubject.IncrementProgress(-1));
            Exceptions.Expect<ArgumentOutOfRangeException>(() => testSubject.IncrementProgress(12));

            // Check successful case (the last valid one)
            testSubject.IncrementProgress(11);
            Assert.AreEqual(11, testSubject.CurrentValue);
        }
All Usage Examples Of SonarLint.VisualStudio.Progress.Controller.DeterminateStepProgressNotifier::IncrementProgress