Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added img/consoleAggregatePulseReporter.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified img/consoleAggregateSpinnerReporter.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 20 additions & 0 deletions src/Progress.UnitTest/PercentTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
1 change: 1 addition & 0 deletions src/Progress/Components/Component.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Progress/Components/HearthBeat.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ private void Fill()
{
Array.Fill(_bar, ' ');

if (CurrentPercent.Value < 100)
if (CurrentPercent.IsInRange)
{
_bar[_leftIndex] = _progressSymbol;
_bar[_rightIndex] = _progressSymbol;
Expand Down
2 changes: 1 addition & 1 deletion src/Progress/Components/Pulse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ private void Fill()
{
Array.Fill(_bar, ' ');

if (CurrentPercent.Value < 100)
if (CurrentPercent.IsInRange)
_bar[_index] = _progressSymbol;
}
}
33 changes: 20 additions & 13 deletions src/Progress/Components/Spinner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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 = ' ';
}
}
}
2 changes: 1 addition & 1 deletion src/Progress/Progress.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<PropertyGroup>
<PackageId>Progress</PackageId>
<Version>2.0.0</Version>
<Version>2.0.1</Version>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<Authors>Gerard Castello</Authors>
<Title>Report progress with ease</Title>
Expand Down