Remaining time estimate
This commit is contained in:
@@ -30,6 +30,14 @@
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="Castle.Core, Version=3.3.0.0, Culture=neutral, PublicKeyToken=407dd0808d44fbdc, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Castle.Core.3.3.3\lib\net45\Castle.Core.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="Moq, Version=4.5.30.0, Culture=neutral, PublicKeyToken=69f491c39445e920, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Moq.4.5.30\lib\net45\Moq.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="nunit.framework, Version=3.2.1.0, Culture=neutral, PublicKeyToken=2638cd05610744eb, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\NUnit.3.2.1\lib\net45\nunit.framework.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
@@ -52,6 +60,7 @@
|
||||
<Compile Include="Remote\PiscalSshClientTests.cs" />
|
||||
<Compile Include="Utility\MemoizerTests.cs" />
|
||||
<Compile Include="Utility\StringExtensionsTests.cs" />
|
||||
<Compile Include="Utility\TimeInProgressEstimaterTests.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="Parsers\LeafInputData\LeafInput-valid.csv">
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="Castle.Core" version="3.3.3" targetFramework="net45" />
|
||||
<package id="Moq" version="4.5.30" targetFramework="net45" />
|
||||
<package id="NUnit" version="3.2.1" targetFramework="net45" />
|
||||
</packages>
|
||||
Reference in New Issue
Block a user