public void ReportProgressTest2() { const int numberOfIterations = 10; var tested = new TestedProgressReporter(); Thread.Sleep(1); Assert.Equal(0L, tested.Elapsed.TotalMilliseconds); Assert.False(tested.IsRunning); tested.Restart(numberOfIterations); const long remainingMsPrevious = long.MaxValue; var elapsedMs = 0.0; for (var i = 0; i < numberOfIterations; ++i) { Assert.True(tested.IsRunning); var from = i; var to = i + 1; Thread.Sleep(1); var remainingMs = tested.RemainingTimeEstimate.TotalMilliseconds; tested.ReportProgress(); elapsedMs = tested.Elapsed.TotalMilliseconds; Assert.True(remainingMsPrevious > remainingMs); } Assert.False(tested.IsRunning); Assert.Equal(elapsedMs, tested.Elapsed.TotalMilliseconds); }
public void ResetResetsCompletely() { // Arrange var tested = new TestedProgressReporter(); // Act tested.Restart(2); tested.ReportProgress(); tested.ReportProgress(); tested.Reset(); Assert.True(tested.IsIdle); Assert.False(tested.IsRunning); Assert.False(tested.UsedAtLestOnce); Assert.Equal(default(TimeSpan), tested.AverageCycleDuration); Assert.Equal(0, tested.AverageCycleStep); Assert.Equal(0, tested.CompletedPercent); Assert.Equal(0, tested.CompletedRawValue); Assert.Equal(0, tested.CurrentCycle); Assert.Equal(0, tested.CurrentRawValue); Assert.Equal(0, tested.LastCycleStep); Assert.Equal(0, tested.PreviousRawValue); Assert.Equal(0, tested.RemainingCyclesEstimate); Assert.Equal(100, tested.RemainingPercent); Assert.Equal(0, tested.RemainingRawValue); Assert.Equal(default(TimeSpan), tested.RemainingTimeEstimate); Assert.Equal(default(TimeSpan), tested.Elapsed); Assert.Equal(0, tested.TargetCycleEstimate); Assert.Equal(0, tested.TargetRawValue); }
public void ProgressReporterCompletedPercentIsCorrect2() { var tested = new TestedProgressReporter(); tested.Restart(2); Assert.Equal(0, tested.CompletedPercent); tested.ReportProgress(); Assert.Equal(50.0, tested.CompletedPercent); tested.ReportProgress(); Assert.Equal(100.0, tested.CompletedPercent); }
public void FinishTest() { const int numberOfIterations = 5; var tested = new TestedProgressReporter(); Assert.False(tested.IsRunning); tested.Restart(numberOfIterations * 2); for (var i = 0; i < numberOfIterations; ++i) { Assert.True(tested.IsRunning); tested.ReportProgress(); } Assert.False(tested.IsIdle); Assert.True(tested.IsRunning); tested.Pause(); Assert.False(tested.IsRunning); Assert.True(tested.IsIdle); }