Seraphina/Seraphina.Tests/SkillInfoTest.cs

71 lines
2.2 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using FsCheck;
using FsCheck.Xunit;
using Seraphina.Core;
using Xunit;
namespace Seraphina.Tests
{
public class SkillInfoTest
{
static readonly List<SkillPoint> validList = new List<SkillPoint> { 1, 2, 3, 4 };
[Fact]
public void Ctor_ThrowsOnNullAndEmptyId()
{
Assert.Throws<ArgumentNullException>("id", () => new SkillInfo(null, "test", validList));
Assert.Throws<ArgumentException>("id", () => new SkillInfo("", "test", validList));
}
[Fact]
public void Ctor_ThrowsOnNullAndEmptyName()
{
Assert.Throws<ArgumentNullException>("name", () => new SkillInfo("test", null, validList));
Assert.Throws<ArgumentException>("name", () => new SkillInfo("test", "", validList));
}
[Fact]
public void Ctor_ThrowsOnNullAndEmptySkillCosts()
{
Assert.Throws<ArgumentNullException>("skillPointCosts", () => new SkillInfo("test", "test", null));
Assert.Throws<ArgumentException>("skillPointCosts", () => new SkillInfo("test", "test", new List<SkillPoint> { }));
}
[Fact]
public void Ctor_ThrowsOnNullDescription()
{
Assert.Throws<ArgumentNullException>("description", () => new SkillInfo("test", "test", null, validList));
}
public static IEnumerable<object[]> GetSkillInvalidLengths()
{
for (int i = 1; i < SkillInfo.NumLevelUpgrades; i++)
{
yield return new object[] { i };
}
}
[Theory]
[MemberData(nameof(GetSkillInvalidLengths))]
public void Ctor_ThrowsWhenSkillCostsTooShort(int length)
{
var skillCosts = Enumerable.Range(0, length).Select(x => new SkillPoint(x)).ToList();
Assert.Throws<ArgumentException>("skillPointCosts", () => new SkillInfo("test", "test", skillCosts));
}
[Fact]
public void Ctor_AcceptsNormalParameters()
{
var _ = new SkillInfo("test", "test", validList);
// Shouldn't do anything special here, just pass.
}
}
}