Skip to content

Commit

Permalink
Test and fix PatchProgress.ProgressFraction
Browse files Browse the repository at this point in the history
Patches are now only counted after needs are checked, so this shouldn't
consider needs unsatisfied nodes
  • Loading branch information
blowfishpro committed Oct 13, 2017
1 parent e9c341a commit b0e02e0
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
2 changes: 1 addition & 1 deletion ModuleManager/Progress/PatchProgress.cs
Expand Up @@ -16,7 +16,7 @@ public float ProgressFraction
get
{
if (Counter.totalPatches > 0)
return (Counter.appliedPatches + Counter.needsUnsatisfied) / (float)Counter.totalPatches;
return Counter.appliedPatches / (float)Counter.totalPatches;
return 0;
}
}
Expand Down
32 changes: 32 additions & 0 deletions ModuleManagerTests/Progress/PatchProgressTest.cs
Expand Up @@ -276,5 +276,37 @@ public void TestException__Url()
Assert.Equal(2, progress.Counter.errorFiles["abc/def.cfg"]);
logger.Received().Exception("An exception was tossed", e2);
}

[Fact]
public void TestProgressFraction()
{
Assert.Equal(0, progress.ProgressFraction);

progress.Counter.needsUnsatisfied.Increment();
progress.Counter.needsUnsatisfied.Increment();

progress.Counter.totalPatches.Increment();
progress.Counter.totalPatches.Increment();
progress.Counter.totalPatches.Increment();
progress.Counter.totalPatches.Increment();

Assert.Equal(0, progress.ProgressFraction);

progress.Counter.appliedPatches.Increment();

Assert.Equal(0.25, progress.ProgressFraction);

progress.Counter.appliedPatches.Increment();

Assert.Equal(0.5, progress.ProgressFraction);

progress.Counter.appliedPatches.Increment();

Assert.Equal(0.75, progress.ProgressFraction);

progress.Counter.appliedPatches.Increment();

Assert.Equal(1, progress.ProgressFraction);
}
}
}

0 comments on commit b0e02e0

Please sign in to comment.