switched to xunit

This commit is contained in:
2024-05-03 18:49:51 -06:00
parent aab38c3e9b
commit 26bf2bbbd1
34 changed files with 643 additions and 298 deletions

View File

@@ -3,7 +3,7 @@ using CanvasModel.EnrollmentTerms;
public class DeserializationTests
{
[Test]
[Fact]
public void TestTerm()
{

View File

@@ -1,6 +1,6 @@
public class CalendarMonthTests
{
[Test]
[Fact]
public void TestCalendarMonthCanGetFirstWeek()
{
var month = new CalendarMonth(2023, 2);
@@ -12,7 +12,7 @@ public class CalendarMonthTests
month.Weeks.First().Should().BeEquivalentTo(expectedFirstWeek);
}
[Test]
[Fact]
public void TestCanGetAnotherMonthsFirstWeek()
{
var month = new CalendarMonth(2023, 4);
@@ -24,7 +24,7 @@ public class CalendarMonthTests
month.Weeks.First().Should().BeEquivalentTo(expectedFirstWeek);
}
[Test]
[Fact]
public void TestCorrectNumberOfWeeks()
{
var month = new CalendarMonth(2023, 4);
@@ -32,7 +32,7 @@ public class CalendarMonthTests
month.Weeks.Count().Should().Be(6);
}
[Test]
[Fact]
public void TestLastWeekIsCorrect()
{
var month = new CalendarMonth(2023, 4);

View File

@@ -2,7 +2,7 @@
// public class ConfigurationTests
// {
// [Test]
// [Fact]
// public void TestCanCreateConfigFromTermAndDays()
// {
// DateTime startAt = new DateTime(2022, 1, 1);

View File

@@ -1,6 +1,6 @@
// public class ModuleTests
// {
// [Test]
// [Fact]
// public void CanAddModule()
// {
// var manager = new ModuleManager();
@@ -11,7 +11,7 @@
// manager.Modules.First().Should().Be(module);
// }
// [Test]
// [Fact]
// public void CanAddAssignmentToCorrectModule()
// {
// var manager = new ModuleManager();

View File

@@ -4,7 +4,7 @@
// public class SemesterPlannerTests
// {
// [Test]
// [Fact]
// public void TestCanCreatePlanner()
// {
@@ -19,7 +19,7 @@
// semester.Months.Count().Should().Be(1);
// }
// [Test]
// [Fact]
// public void TestNewPlannerHasCorrectNumberOfMonths()
// {
// var config = new SemesterCalendarConfig(
@@ -33,7 +33,7 @@
// semester.Months.Count().Should().Be(2);
// }
// [Test]
// [Fact]
// public void TestNewPlannerHandlesTermsThatWrapYears()
// {
// var config = new SemesterCalendarConfig(
@@ -47,7 +47,7 @@
// semester.Months.Count().Should().Be(2);
// }
// [Test]
// [Fact]
// public void TestSemesterGetsCorrectMonths()
// {
// var config = new SemesterCalendarConfig(
@@ -63,7 +63,7 @@
// }
// [Test]
// [Fact]
// public void TestMonthsCanWrapYears()
// {
// var config = new SemesterCalendarConfig(
@@ -81,7 +81,7 @@
// semester.Months.Last().Year.Should().Be(2023);
// }
// [Test]
// [Fact]
// public void TestSemesterTracksDaysOfWeek()
// {
// DayOfWeek[] days = new DayOfWeek[] { DayOfWeek.Monday };

View File

@@ -9,15 +9,25 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="akka.testkit" Version="1.5.18" />
<PackageReference Include="Akka.TestKit.Xunit2" Version="1.5.18" />
<PackageReference Include="FluentAssertions" Version="6.8.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.3.2" />
<PackageReference Include="Moq" Version="4.18.4" />
<PackageReference Include="nsubstitute" Version="5.1.0" />
<PackageReference Include="NUnit" Version="3.13.3" />
<PackageReference Include="NUnit3TestAdapter" Version="4.2.1" />
<PackageReference Include="NUnit.Analyzers" Version="3.3.0" />
<PackageReference Include="coverlet.collector" Version="3.1.2" />
<PackageReference Include="RestSharp" Version="108.0.3" />
<PackageReference Include="NSubstitute.Analyzers.CSharp" Version="1.0.17">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="xunit" Version="2.7.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.7">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="coverlet.collector" Version="6.0.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>
<ItemGroup>

View File

@@ -2,7 +2,7 @@ using LocalModels;
public class AssignmentMarkdownTests
{
[Test]
[Fact]
public void TestCanParseAssignmentSettings()
{
var assignment = new LocalAssignment()
@@ -24,7 +24,7 @@ public class AssignmentMarkdownTests
var parsedAssignment = LocalAssignment.ParseMarkdown(assignmentMarkdown);
parsedAssignment.Should().BeEquivalentTo(assignment);
}
[Test]
[Fact]
public void AssignmentWithEmptyRubric_CanBeParsed()
{
var assignment = new LocalAssignment()
@@ -43,7 +43,7 @@ public class AssignmentMarkdownTests
var parsedAssignment = LocalAssignment.ParseMarkdown(assignmentMarkdown);
parsedAssignment.Should().BeEquivalentTo(assignment);
}
[Test]
[Fact]
public void AssignmentWithEmptySubmissionTypes_CanBeParsed()
{
var assignment = new LocalAssignment()
@@ -66,7 +66,7 @@ public class AssignmentMarkdownTests
parsedAssignment.Should().BeEquivalentTo(assignment);
}
[Test]
[Fact]
public void AssignmentWithoutLockAtDate_CanBeParsed()
{
var assignment = new LocalAssignment()
@@ -89,7 +89,7 @@ public class AssignmentMarkdownTests
parsedAssignment.Should().BeEquivalentTo(assignment);
}
[Test]
[Fact]
public void AssignmentWithoutDescription_CanBeParsed()
{
var assignment = new LocalAssignment()
@@ -111,7 +111,7 @@ public class AssignmentMarkdownTests
var parsedAssignment = LocalAssignment.ParseMarkdown(assignmentMarkdown);
parsedAssignment.Should().BeEquivalentTo(assignment);
}
[Test]
[Fact]
public void Assignments_CanHaveThreeDashes()
{
var assignment = new LocalAssignment()

View File

@@ -5,14 +5,13 @@ using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging.Abstractions;
using NSubstitute;
using NUnit.Framework.Internal;
public class FileStorageTests
{
private IFileStorageManager fileManager { get; set; }
private FileStorageManager fileManager { get; set; }
private static string setupTempDirectory()
public FileStorageTests()
{
var tempDirectory = Path.GetTempPath();
var storageDirectory = tempDirectory + "fileStorageTests";
@@ -29,14 +28,6 @@ public class FileStorageTests
dir.Delete(true);
}
return storageDirectory;
}
[SetUp]
public void SetUp()
{
var storageDirectory = setupTempDirectory();
var fileManagerLogger = new MyLogger<FileStorageManager>(NullLogger<FileStorageManager>.Instance);
var markdownLoaderLogger = new MyLogger<CourseMarkdownLoader>(NullLogger<CourseMarkdownLoader>.Instance);
var markdownSaverLogger = new MyLogger<MarkdownCourseSaver>(NullLogger<MarkdownCourseSaver>.Instance);
@@ -52,7 +43,7 @@ public class FileStorageTests
fileManager = new FileStorageManager(fileManagerLogger, markdownLoader, markdownSaver, otherLogger, fileConfiguration);
}
[Test]
[Fact]
public async Task EmptyCourse_CanBeSavedAndLoaded()
{
LocalCourse testCourse = new LocalCourse
@@ -69,7 +60,7 @@ public class FileStorageTests
loadedCourse.Should().BeEquivalentTo(testCourse);
}
[Test]
[Fact]
public async Task CourseSettings_CanBeSavedAndLoaded()
{
LocalCourse testCourse = new()
@@ -95,7 +86,7 @@ public class FileStorageTests
}
[Test]
[Fact]
public async Task EmptyCourseModules_CanBeSavedAndLoaded()
{
LocalCourse testCourse = new()
@@ -119,7 +110,7 @@ public class FileStorageTests
loadedCourse.Modules.Should().BeEquivalentTo(testCourse.Modules);
}
[Test]
[Fact]
public async Task CourseModules_WithAssignments_CanBeSavedAndLoaded()
{
LocalCourse testCourse = new()
@@ -160,7 +151,7 @@ public class FileStorageTests
}
[Test]
[Fact]
public async Task CourseModules_WithQuizzes_CanBeSavedAndLoaded()
{
LocalCourse testCourse = new()
@@ -204,7 +195,7 @@ public class FileStorageTests
}
[Test]
[Fact]
public async Task MarkdownStorage_FullyPopulated_DoesNotLoseData()
{
LocalCourse testCourse = new()
@@ -271,7 +262,7 @@ public class FileStorageTests
}
[Test]
[Fact]
public async Task MarkdownStorage_CanPersistPages()
{
LocalCourse testCourse = new()

View File

@@ -2,7 +2,7 @@ using LocalModels;
public class PageMarkdownTests
{
[Test]
[Fact]
public void TestCanParsePage()
{
var page = new LocalCoursePage

View File

@@ -2,7 +2,7 @@ using LocalModels;
public class MatchingTests
{
[Test]
[Fact]
public void CanParseMatchingQuestion()
{
var rawMarkdownQuiz = @"
@@ -29,7 +29,7 @@ Match the following terms & definitions
firstQuestion.Answers.First().MatchedText.Should().Be("a single command to be executed");
}
[Test]
[Fact]
public void CanCreateMarkdownForMatchingQuesiton()
{
var rawMarkdownQuiz = @"
@@ -59,7 +59,7 @@ Match the following terms & definitions
^ keyword - reserved word that has special meaning in a program (e.g. class, void, static, etc.)";
questionMarkdown.Should().Contain(expectedMarkdown);
}
[Test]
[Fact]
public void WhitespaceIsOptional()
{
var rawMarkdownQuiz = @"

View File

@@ -3,7 +3,7 @@ using LocalModels;
public class MultipleAnswersTests
{
[Test]
[Fact]
public void QuzMarkdownIncludesMultipleAnswerQuestion()
{
var quiz = new LocalQuiz()
@@ -43,7 +43,7 @@ oneline question
markdown.Should().Contain(expectedQuestionString);
}
[Test]
[Fact]
public void CanParseQuestionWithMultipleAnswers()
{
var rawMarkdownQuiz = @"
@@ -81,7 +81,7 @@ Which events are triggered when the user clicks on an input field?
}
[Test]
[Fact]
public void CanUseBracesInAnswerFormultipleAnswer()
{
var rawMarkdownQuestion = @"
@@ -95,7 +95,7 @@ Which events are triggered when the user clicks on an input field?
question.Answers.Count().Should().Be(2);
}
[Test]
[Fact]
public void CanUseBracesInAnswerFormultipleAnswer_MultiLine()
{
var rawMarkdownQuestion = @"

View File

@@ -2,7 +2,7 @@ using LocalModels;
public class MultipleChoiceTests
{
[Test]
[Fact]
public void QuzMarkdownIncludesMultipleChoiceQuestion()
{
var quiz = new LocalQuiz()
@@ -58,7 +58,7 @@ endline
}
[Test]
[Fact]
public void LetterOptionalForMultipleChoice()
{

View File

@@ -4,7 +4,7 @@ using LocalModels;
public class QuizDeterministicChecks
{
[Test]
[Fact]
public void SerializationIsDeterministic_EmptyQuiz()
{
var quiz = new LocalQuiz()
@@ -23,7 +23,7 @@ public class QuizDeterministicChecks
parsedQuiz.Should().BeEquivalentTo(quiz);
}
[Test]
[Fact]
public void SerializationIsDeterministic_ShowCorrectAnswers()
{
var quiz = new LocalQuiz()
@@ -43,7 +43,7 @@ public class QuizDeterministicChecks
parsedQuiz.Should().BeEquivalentTo(quiz);
}
[Test]
[Fact]
public void SerializationIsDeterministic_ShortAnswer()
{
var quiz = new LocalQuiz()
@@ -71,7 +71,7 @@ public class QuizDeterministicChecks
parsedQuiz.Should().BeEquivalentTo(quiz);
}
[Test]
[Fact]
public void SerializationIsDeterministic_Essay()
{
var quiz = new LocalQuiz()
@@ -99,7 +99,7 @@ public class QuizDeterministicChecks
parsedQuiz.Should().BeEquivalentTo(quiz);
}
[Test]
[Fact]
public void SerializationIsDeterministic_MultipleAnswer()
{
var quiz = new LocalQuiz()
@@ -138,7 +138,7 @@ public class QuizDeterministicChecks
parsedQuiz.Should().BeEquivalentTo(quiz);
}
[Test]
[Fact]
public void SerializationIsDeterministic_MultipleChoice()
{
var quiz = new LocalQuiz()
@@ -176,7 +176,7 @@ public class QuizDeterministicChecks
var parsedQuiz = LocalQuiz.ParseMarkdown(quizMarkdown);
parsedQuiz.Should().BeEquivalentTo(quiz);
}
[Test]
[Fact]
public void SerializationIsDeterministic_Matching()
{
var quiz = new LocalQuiz()

View File

@@ -4,7 +4,7 @@ using LocalModels;
// try to follow syntax from https://github.com/gpoore/text2qti
public class QuizMarkdownTests
{
[Test]
[Fact]
public void CanSerializeQuizToMarkdown()
{
var quiz = new LocalQuiz()
@@ -37,7 +37,7 @@ this is my description in markdown
}
[Test]
[Fact]
public void TestCanParseMarkdownQuizWithNoQuestions()
{
var rawMarkdownQuiz = new StringBuilder();
@@ -68,7 +68,7 @@ this is my description in markdown
quiz.AllowedAttempts.Should().Be(-1);
quiz.Description.Should().Be(expectedDescription.ToString());
}
[Test]
[Fact]
public void TestCanParseMarkdownQuizPassword()
{
@@ -94,7 +94,7 @@ this is my description in markdown
quiz.Password.Should().Be(password);
}
[Test]
[Fact]
public void TestCanParseMarkdownQuiz_CanConfigureToShowCorrectAnswers()
{
var rawMarkdownQuiz = new StringBuilder();
@@ -118,7 +118,7 @@ this is my description in markdown
quiz.showCorrectAnswers.Should().BeFalse();
}
[Test]
[Fact]
public void TestCanParseQuizWithQuestions()
{
var rawMarkdownQuiz = @"
@@ -159,7 +159,7 @@ b) false
firstQuestion.Answers.ElementAt(1).Text.Should().Contain("endline");
}
[Test]
[Fact]
public void CanParseMultipleQuestions()
{
var rawMarkdownQuiz = @"
@@ -192,7 +192,7 @@ b) false
secondQuestion.QuestionType.Should().Be(QuestionType.MULTIPLE_CHOICE);
}
[Test]
[Fact]
public void ShortAnswerToMarkdown_IsCorrect()
{
var rawMarkdownQuiz = @"
@@ -220,7 +220,7 @@ Which events are triggered when the user clicks on an input field?
short_answer";
questionMarkdown.Should().Contain(expectedMarkdown);
}
[Test]
[Fact]
public void NegativePoints_IsAllowed()
{
var rawMarkdownQuiz = @"
@@ -244,7 +244,7 @@ short answer
var firstQuestion = quiz.Questions.First();
firstQuestion.Points.Should().Be(-4);
}
[Test]
[Fact]
public void FloatingPointPoints_IsAllowed()
{
var rawMarkdownQuiz = @"

View File

@@ -2,7 +2,7 @@ using LocalModels;
public class TextAnswerTests
{
[Test]
[Fact]
public void CanParseEssay()
{
var rawMarkdownQuiz = @"
@@ -28,7 +28,7 @@ essay
firstQuestion.Text.Should().NotContain("essay");
}
[Test]
[Fact]
public void CanParseShortAnswer()
{
var rawMarkdownQuiz = @"
@@ -54,7 +54,7 @@ short answer
firstQuestion.Text.Should().NotContain("short answer");
}
[Test]
[Fact]
public void ShortAnswerToMarkdown_IsCorrect()
{
var rawMarkdownQuiz = @"
@@ -83,7 +83,7 @@ short_answer";
questionMarkdown.Should().Contain(expectedMarkdown);
}
[Test]
[Fact]
public void EssayQuestionToMarkdown_IsCorrect()
{
var rawMarkdownQuiz = @"

View File

@@ -3,7 +3,7 @@ using LocalModels;
public class RubricMarkdownTests
{
[Test]
[Fact]
public void TestCanParseOneItem()
{
var rawRubric = @"
@@ -17,7 +17,7 @@ public class RubricMarkdownTests
rubric.First().Points.Should().Be(2);
}
[Test]
[Fact]
public void TestCanParseMultipleItems()
{
var rawRubric = @"
@@ -32,7 +32,7 @@ public class RubricMarkdownTests
rubric.ElementAt(1).Points.Should().Be(3);
}
[Test]
[Fact]
public void TestCanParseSinglePoint()
{
var rawRubric = @"
@@ -45,7 +45,7 @@ public class RubricMarkdownTests
rubric.First().Points.Should().Be(1);
}
[Test]
[Fact]
public void TestCanParseSingleExtraCredit_LowerCase()
{
var rawRubric = @"
@@ -57,7 +57,7 @@ public class RubricMarkdownTests
rubric.First().Label.Should().Be("(extra credit) this is the task");
}
[Test]
[Fact]
public void TestCanParseSingleExtraCredit_UpperCase()
{
var rawRubric = @"
@@ -69,7 +69,7 @@ public class RubricMarkdownTests
rubric.First().Label.Should().Be("(Extra Credit) this is the task");
}
[Test]
[Fact]
public void TestCanParseFloatingPointNubmers()
{
var rawRubric = @"
@@ -79,7 +79,7 @@ public class RubricMarkdownTests
var rubric = LocalAssignment.ParseRubricMarkdown(rawRubric);
rubric.First().Points.Should().Be(1.5);
}
[Test]
[Fact]
public void TestCanParseNegativeNubmers()
{
var rawRubric = @"
@@ -89,7 +89,7 @@ public class RubricMarkdownTests
var rubric = LocalAssignment.ParseRubricMarkdown(rawRubric);
rubric.First().Points.Should().Be(-2.0);
}
[Test]
[Fact]
public void TestCanParseNegativeFloatingPointNubmers()
{
var rawRubric = @"

View File

@@ -9,7 +9,7 @@
// public class ICanvasServiceTests
// {
// [Test]
// [Fact]
// public async Task CanReadCanvasSemesters()
// {
// var expectedTerms = new EnrollmentTermModel[] {
@@ -28,7 +28,7 @@
// canvasTerms.Should().BeEquivalentTo(expectedTerms);
// }
// [Test]
// [Fact]
// public async Task CanGetActiveTerms()
// {
// var expectedTerms = new EnrollmentTermModel[] {

View File

@@ -1,3 +1,3 @@
global using System.Text.Json;
global using FluentAssertions;
global using NUnit.Framework;
global using Xunit;

View File

@@ -2,7 +2,7 @@ using Management.Web.Pages.Course.CourseCalendar;
public class MonthDetailTests
{
[Test]
[Fact]
public void TestCanGetMonthName()
{
var calendarMonth = new CalendarMonth(2022, 2);