66 lines
1.7 KiB
C#
66 lines
1.7 KiB
C#
using HSchool.Content;
|
|
|
|
namespace HSchool.Ai.Tests;
|
|
|
|
public class LessonMarkTests
|
|
{
|
|
private static readonly BehaviorDef Rules = new()
|
|
{
|
|
DefName = "Behavior",
|
|
LessonMarkThresholds = BehaviorDef.DefaultLessonMarkThresholds,
|
|
LessonMarkMax = 40,
|
|
LessonMarkWhenNoTeacher = 2,
|
|
};
|
|
|
|
[Fact]
|
|
public void StrongTeacher_MarkIsAtLeastEmptyRoomMark()
|
|
{
|
|
var strongQuality = LessonLearning.Quality(
|
|
hunger: 1f,
|
|
traitOffset: 0,
|
|
teacherSkill: 100f,
|
|
warmth: 1f,
|
|
textbookFactor: 1f);
|
|
var strong = LessonLearning.Mark(strongQuality, Rules);
|
|
var emptyRoom = Rules.LessonMarkWhenNoTeacher!.Value;
|
|
|
|
Assert.True(strong >= emptyRoom);
|
|
Assert.Equal(5, strong);
|
|
Assert.Equal(2, emptyRoom);
|
|
}
|
|
|
|
[Fact]
|
|
public void SameInputs_SameMark()
|
|
{
|
|
var first = LessonLearning.Mark(
|
|
LessonLearning.Quality(0.8f, 4, 70f, 0.9f, 0.5f),
|
|
Rules);
|
|
var second = LessonLearning.Mark(
|
|
LessonLearning.Quality(0.8f, 4, 70f, 0.9f, 0.5f),
|
|
Rules);
|
|
|
|
Assert.Equal(first, second);
|
|
Assert.InRange(first, 2, 5);
|
|
}
|
|
|
|
[Fact]
|
|
public void ZeroMultiplier_YieldsLowestMark()
|
|
{
|
|
var mark = LessonLearning.Mark(
|
|
LessonLearning.Quality(1f, 0, 100f, 1f, textbookFactor: 0f),
|
|
Rules);
|
|
|
|
Assert.Equal(2, mark);
|
|
}
|
|
|
|
[Theory]
|
|
[InlineData(0.85f, 5)]
|
|
[InlineData(0.6f, 4)]
|
|
[InlineData(0.35f, 3)]
|
|
[InlineData(0.34f, 2)]
|
|
public void Thresholds_MapQualityToMark(float quality, int expected)
|
|
{
|
|
Assert.Equal(expected, LessonLearning.Mark(quality, Rules));
|
|
}
|
|
}
|