wrote rubric parsing tests

This commit is contained in:
2023-10-25 10:03:06 -06:00
parent cd2591d76b
commit 1d58166a5c
5 changed files with 208 additions and 16 deletions

View File

@@ -0,0 +1,67 @@
using LocalModels;
public class RubricMarkdownTests
{
[Test]
public void TestCanParseOneItem()
{
var rawRubric = @"
- 2pts: this is the task
";
var rubric = LocalAssignment.ParseRubricMarkdown(rawRubric);
rubric.Count().Should().Be(1);
rubric.First().IsExtraCredit.Should().BeFalse();
rubric.First().Label.Should().Be("this is the task");
rubric.First().Points.Should().Be(2);
}
[Test]
public void TestCanParseMultipleItems()
{
var rawRubric = @"
- 2pts: this is the task
- 3pts: this is the other task
";
var rubric = LocalAssignment.ParseRubricMarkdown(rawRubric);
rubric.Count().Should().Be(2);
rubric.ElementAt(1).IsExtraCredit.Should().BeFalse();
rubric.ElementAt(1).Label.Should().Be("this is the other task");
rubric.ElementAt(1).Points.Should().Be(3);
}
[Test]
public void TestCanParseSinglePoint()
{
var rawRubric = @"
- 1pt: this is the task
";
var rubric = LocalAssignment.ParseRubricMarkdown(rawRubric);
rubric.First().IsExtraCredit.Should().BeFalse();
rubric.First().Label.Should().Be("this is the task");
rubric.First().Points.Should().Be(1);
}
[Test]
public void TestCanParseSingleExtraCredit_LowerCase()
{
var rawRubric = @"
- 1pt: (extra credit) this is the task
";
var rubric = LocalAssignment.ParseRubricMarkdown(rawRubric);
rubric.First().IsExtraCredit.Should().BeTrue();
rubric.First().Label.Should().Be("(extra credit) this is the task");
}
[Test]
public void TestCanParseSingleExtraCredit_UpperCase()
{
var rawRubric = @"
- 1pt: (Extra Credit) this is the task
";
var rubric = LocalAssignment.ParseRubricMarkdown(rawRubric);
rubric.First().IsExtraCredit.Should().BeTrue();
rubric.First().Label.Should().Be("(Extra Credit) this is the task");
}
}