Add LevelCalc unit test

This commit is contained in:
runebaas 2018-01-19 01:17:05 +01:00
parent 11df9d7955
commit fdb38192fe
No known key found for this signature in database
GPG key ID: 2677AF508D0300D6
2 changed files with 50 additions and 1 deletions

View file

@ -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;

View 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);
}
}
}