Remaining time estimate
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using LeafWeb.Core.Entities;
|
||||
using LeafWeb.Core.Utility;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace LeafWeb.Core.Tests.Utility
|
||||
{
|
||||
[TestFixture]
|
||||
public class TimeInProgressEstimaterTests
|
||||
{
|
||||
[Test]
|
||||
public void EstimateTest()
|
||||
{
|
||||
Func<int, int> scaleFunc = i => i*i;
|
||||
|
||||
var obervations =
|
||||
from i in Enumerable.Range(1, 10)
|
||||
let time = scaleFunc(i)
|
||||
select Mock.Of<ILeafInput>(li =>
|
||||
li.InputFiles.Count == i &&
|
||||
li.TimeInProgress == TimeSpan.FromMinutes(time));
|
||||
|
||||
var estimater = new TimeInProgressEstimater(obervations.ToArray());
|
||||
|
||||
Action<int> est = i =>
|
||||
{
|
||||
var query = Mock.Of<ILeafInput>(li => li.InputFiles.Count == i);
|
||||
var estimate = estimater.EstimateTimeInProgress(query);
|
||||
Console.WriteLine($"{i} => {estimate}. {TimeSpan.FromMinutes(scaleFunc(i))}");
|
||||
};
|
||||
|
||||
for (var i = 1; i < 30; i++)
|
||||
est(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user