Add LevelCalc unit test
This commit is contained in:
parent
11df9d7955
commit
fdb38192fe
2 changed files with 50 additions and 1 deletions
|
@ -4,7 +4,7 @@ using System.Linq;
|
||||||
|
|
||||||
namespace Geekbot.net.Lib
|
namespace Geekbot.net.Lib
|
||||||
{
|
{
|
||||||
internal class LevelCalc : ILevelCalc
|
public class LevelCalc : ILevelCalc
|
||||||
{
|
{
|
||||||
private int[] _levels;
|
private int[] _levels;
|
||||||
|
|
||||||
|
|
49
Tests/Lib/LevelCalc.test.cs
Normal file
49
Tests/Lib/LevelCalc.test.cs
Normal file
|
@ -0,0 +1,49 @@
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Geekbot.net.Lib;
|
||||||
|
using Xunit;
|
||||||
|
|
||||||
|
namespace Tests.Lib
|
||||||
|
{
|
||||||
|
public class LevelCalc_test
|
||||||
|
{
|
||||||
|
public static IEnumerable<object[]> LevelCalcTestData
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
yield return new object[]
|
||||||
|
{
|
||||||
|
500,
|
||||||
|
13
|
||||||
|
};
|
||||||
|
|
||||||
|
yield return new object[]
|
||||||
|
{
|
||||||
|
41659,
|
||||||
|
55
|
||||||
|
};
|
||||||
|
|
||||||
|
yield return new object[]
|
||||||
|
{
|
||||||
|
0,
|
||||||
|
1
|
||||||
|
};
|
||||||
|
|
||||||
|
yield return new object[]
|
||||||
|
{
|
||||||
|
4000000,
|
||||||
|
101
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
[Theory, MemberData(nameof(LevelCalcTestData))]
|
||||||
|
public async Task GetLevel(int messages, int expectedResult)
|
||||||
|
{
|
||||||
|
var levelCalc = new LevelCalc();
|
||||||
|
var result = levelCalc.GetLevel(messages);
|
||||||
|
Assert.Equal(result, expectedResult);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue