diff --git a/img/consoleAggregatePulseReporter.gif b/img/consoleAggregatePulseReporter.gif new file mode 100644 index 0000000..9b857d4 Binary files /dev/null and b/img/consoleAggregatePulseReporter.gif differ diff --git a/img/consoleAggregateSpinnerReporter.gif b/img/consoleAggregateSpinnerReporter.gif index 2ab0c8d..5582228 100644 Binary files a/img/consoleAggregateSpinnerReporter.gif and b/img/consoleAggregateSpinnerReporter.gif differ diff --git a/src/Progress.UnitTest/PercentTests.cs b/src/Progress.UnitTest/PercentTests.cs index e142f17..d76ac00 100644 --- a/src/Progress.UnitTest/PercentTests.cs +++ b/src/Progress.UnitTest/PercentTests.cs @@ -23,4 +23,24 @@ public void GivenPercent_WhenDisplaying_ReturnsProperOutput(ulong count, string // Assert actual.Should().Be(expectedOutput); } + + [Theory] + [InlineData(0, false)] + [InlineData(1, true)] + [InlineData(3, true)] + [InlineData(50, true)] + [InlineData(75, true)] + [InlineData(100, false)] + [InlineData(120, false)] + public void GivenPercent_WhenCheckingIfInRange_ReturnsExpected(ulong count, bool expected) + { + // Arrange + var percent = new Component.Percent(100, count); + + // Act + bool actual = percent.IsInRange; + + // Assert + actual.Should().Be(expected); + } } \ No newline at end of file diff --git a/src/Progress/Components/Component.cs b/src/Progress/Components/Component.cs index 8d1d336..687a01d 100644 --- a/src/Progress/Components/Component.cs +++ b/src/Progress/Components/Component.cs @@ -25,6 +25,7 @@ public Percent(ulong items, ulong count) } public double Value => _percent * 100; + public bool IsInRange => Value > 0 && Value < 100; public override string ToString() => _percent.ToString("P02", Culture); } diff --git a/src/Progress/Components/HearthBeat.cs b/src/Progress/Components/HearthBeat.cs index d78b51b..330b3fa 100644 --- a/src/Progress/Components/HearthBeat.cs +++ b/src/Progress/Components/HearthBeat.cs @@ -73,7 +73,7 @@ private void Fill() { Array.Fill(_bar, ' '); - if (CurrentPercent.Value < 100) + if (CurrentPercent.IsInRange) { _bar[_leftIndex] = _progressSymbol; _bar[_rightIndex] = _progressSymbol; diff --git a/src/Progress/Components/Pulse.cs b/src/Progress/Components/Pulse.cs index ba2f6b2..ffa7a96 100644 --- a/src/Progress/Components/Pulse.cs +++ b/src/Progress/Components/Pulse.cs @@ -55,7 +55,7 @@ private void Fill() { Array.Fill(_bar, ' '); - if (CurrentPercent.Value < 100) + if (CurrentPercent.IsInRange) _bar[_index] = _progressSymbol; } } diff --git a/src/Progress/Components/Spinner.cs b/src/Progress/Components/Spinner.cs index 46e5e06..7308846 100644 --- a/src/Progress/Components/Spinner.cs +++ b/src/Progress/Components/Spinner.cs @@ -33,20 +33,27 @@ public override string ToString() private void Fill() { - _current = _counter switch + if (CurrentPercent.IsInRange) { - 1 => '/', - 2 => '-', - 3 => '\\', - 5 => '/', - 6 => '-', - 7 => '\\', - _ => '|' - }; - - if (_counter == 7) - _counter = 0; + _current = _counter switch + { + 1 => '/', + 2 => '-', + 3 => '\\', + 5 => '/', + 6 => '-', + 7 => '\\', + _ => '|' + }; + + if (_counter == 7) + _counter = 0; + else + _counter++; + } else - _counter++; + { + _current = ' '; + } } } diff --git a/src/Progress/Progress.csproj b/src/Progress/Progress.csproj index de98ba7..37b5589 100644 --- a/src/Progress/Progress.csproj +++ b/src/Progress/Progress.csproj @@ -6,7 +6,7 @@ Progress - 2.0.0 + 2.0.1 MIT Gerard Castello Report progress with ease