2020-03-26 21:31:25 +00:00
|
|
|
|
using Wabbajack.Lib;
|
|
|
|
|
using Xunit;
|
2020-01-11 23:17:55 +00:00
|
|
|
|
|
|
|
|
|
namespace Wabbajack.Test
|
|
|
|
|
{
|
|
|
|
|
public class ABatchProcessorTests
|
|
|
|
|
{
|
|
|
|
|
#region CalculateThreadsToUse
|
2020-03-26 21:31:25 +00:00
|
|
|
|
[Fact]
|
2020-01-11 23:17:55 +00:00
|
|
|
|
public void Manual_OverRecommended()
|
|
|
|
|
{
|
2020-03-26 21:31:25 +00:00
|
|
|
|
Assert.Equal(8, ABatchProcessor.CalculateThreadsToUse(
|
2020-01-11 23:17:55 +00:00
|
|
|
|
recommendedCount: 8,
|
|
|
|
|
manual: true,
|
|
|
|
|
manualMax: byte.MaxValue,
|
|
|
|
|
targetUsage: 1.0d));
|
|
|
|
|
}
|
|
|
|
|
|
2020-03-26 21:31:25 +00:00
|
|
|
|
[Fact]
|
2020-01-11 23:17:55 +00:00
|
|
|
|
public void Manual_NeedsTrimming()
|
|
|
|
|
{
|
2020-03-26 21:31:25 +00:00
|
|
|
|
Assert.Equal(5, ABatchProcessor.CalculateThreadsToUse(
|
2020-01-11 23:17:55 +00:00
|
|
|
|
recommendedCount: 8,
|
|
|
|
|
manual: true,
|
|
|
|
|
manualMax: 5,
|
|
|
|
|
targetUsage: 1.0d));
|
|
|
|
|
}
|
|
|
|
|
|
2020-03-26 21:31:25 +00:00
|
|
|
|
[Fact]
|
2020-01-11 23:17:55 +00:00
|
|
|
|
public void Manual_Zero()
|
|
|
|
|
{
|
2020-03-26 21:31:25 +00:00
|
|
|
|
Assert.Equal(1, ABatchProcessor.CalculateThreadsToUse(
|
2020-01-11 23:17:55 +00:00
|
|
|
|
recommendedCount: 8,
|
|
|
|
|
manual: true,
|
|
|
|
|
manualMax: 0,
|
|
|
|
|
targetUsage: 1.0d));
|
|
|
|
|
}
|
|
|
|
|
|
2020-03-26 21:31:25 +00:00
|
|
|
|
[Fact]
|
2020-01-11 23:17:55 +00:00
|
|
|
|
public void Auto_Full()
|
|
|
|
|
{
|
2020-03-26 21:31:25 +00:00
|
|
|
|
Assert.Equal(8, ABatchProcessor.CalculateThreadsToUse(
|
2020-01-11 23:17:55 +00:00
|
|
|
|
recommendedCount: 8,
|
|
|
|
|
manual: false,
|
|
|
|
|
manualMax: byte.MaxValue,
|
|
|
|
|
targetUsage: 1.0d));
|
|
|
|
|
}
|
|
|
|
|
|
2020-03-26 21:31:25 +00:00
|
|
|
|
[Fact]
|
2020-01-11 23:17:55 +00:00
|
|
|
|
public void Auto_Half()
|
|
|
|
|
{
|
2020-03-26 21:31:25 +00:00
|
|
|
|
Assert.Equal(4, ABatchProcessor.CalculateThreadsToUse(
|
2020-01-11 23:17:55 +00:00
|
|
|
|
recommendedCount: 8,
|
|
|
|
|
manual: false,
|
|
|
|
|
manualMax: byte.MaxValue,
|
|
|
|
|
targetUsage: 0.5d));
|
|
|
|
|
}
|
|
|
|
|
|
2020-03-26 21:31:25 +00:00
|
|
|
|
[Fact]
|
2020-01-11 23:17:55 +00:00
|
|
|
|
public void Auto_Zero()
|
|
|
|
|
{
|
2020-03-26 21:31:25 +00:00
|
|
|
|
Assert.Equal(1, ABatchProcessor.CalculateThreadsToUse(
|
2020-01-11 23:17:55 +00:00
|
|
|
|
recommendedCount: 8,
|
|
|
|
|
manual: false,
|
|
|
|
|
manualMax: byte.MaxValue,
|
|
|
|
|
targetUsage: 0d));
|
|
|
|
|
}
|
|
|
|
|
|
2020-03-26 21:31:25 +00:00
|
|
|
|
[Fact]
|
2020-01-11 23:17:55 +00:00
|
|
|
|
public void Auto_OverAllowed()
|
|
|
|
|
{
|
2020-03-26 21:31:25 +00:00
|
|
|
|
Assert.Equal(8, ABatchProcessor.CalculateThreadsToUse(
|
2020-01-11 23:17:55 +00:00
|
|
|
|
recommendedCount: 8,
|
|
|
|
|
manual: false,
|
|
|
|
|
manualMax: byte.MaxValue,
|
|
|
|
|
targetUsage: 2d));
|
|
|
|
|
}
|
|
|
|
|
|
2020-03-26 21:31:25 +00:00
|
|
|
|
[Fact]
|
2020-01-11 23:17:55 +00:00
|
|
|
|
public void Auto_UnderAllowed()
|
|
|
|
|
{
|
2020-03-26 21:31:25 +00:00
|
|
|
|
Assert.Equal(8, ABatchProcessor.CalculateThreadsToUse(
|
2020-01-11 23:17:55 +00:00
|
|
|
|
recommendedCount: 8,
|
|
|
|
|
manual: false,
|
|
|
|
|
manualMax: byte.MaxValue,
|
|
|
|
|
targetUsage: -2d));
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
}
|
|
|
|
|
}
|