mirror of
https://github.com/alexmickelson/canvasManagement.git
synced 2026-03-25 23:28:33 -06:00
tests allow for pages to be stored and retrieved
This commit is contained in:
@@ -43,8 +43,8 @@ public class FileStorageTests
|
||||
var otherLogger = NullLoggerFactory.Instance.CreateLogger<FileStorageManager>();
|
||||
Environment.SetEnvironmentVariable("storageDirectory", storageDirectory);
|
||||
var config = new ConfigurationBuilder()
|
||||
.AddEnvironmentVariables()
|
||||
.Build();
|
||||
.AddEnvironmentVariables()
|
||||
.Build();
|
||||
var fileConfiguration = new FileConfiguration(config);
|
||||
|
||||
var markdownLoader = new CourseMarkdownLoader(markdownLoaderLogger, fileConfiguration);
|
||||
@@ -252,4 +252,39 @@ public class FileStorageTests
|
||||
|
||||
loadedCourse.Should().BeEquivalentTo(testCourse);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
[Test]
|
||||
public async Task MarkdownStorage_CanPersistPages()
|
||||
{
|
||||
LocalCourse testCourse = new() {
|
||||
Settings = new () {
|
||||
AssignmentGroups = [],
|
||||
Name = "Test Course with page",
|
||||
DaysOfWeek = [DayOfWeek.Monday, DayOfWeek.Wednesday],
|
||||
StartDate = new DateTime(),
|
||||
EndDate = new DateTime(),
|
||||
DefaultDueTime = new() { Hour = 1, Minute = 59 },
|
||||
},
|
||||
Modules = [
|
||||
new(){
|
||||
Name = "page test module",
|
||||
Pages = [
|
||||
new () {
|
||||
Name = "test page persistence",
|
||||
DueDateForOrdering = new DateTime(),
|
||||
Text = "this is some\n## markdown\n"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
await fileManager.SaveCourseAsync(testCourse, null);
|
||||
|
||||
var loadedCourses = await fileManager.LoadSavedMarkdownCourses();
|
||||
var loadedCourse = loadedCourses.First(c => c.Settings.Name == testCourse.Settings.Name);
|
||||
|
||||
loadedCourse.Should().BeEquivalentTo(testCourse);
|
||||
}
|
||||
}
|
||||
|
||||
21
Management.Test/Markdown/PageMarkdownTests.cs
Normal file
21
Management.Test/Markdown/PageMarkdownTests.cs
Normal file
@@ -0,0 +1,21 @@
|
||||
using LocalModels;
|
||||
|
||||
public class PageMarkdownTests
|
||||
{
|
||||
[Test]
|
||||
public void TestCanParsePage()
|
||||
{
|
||||
var page = new LocalCoursePage
|
||||
{
|
||||
Name = "test title",
|
||||
Text = "test text content",
|
||||
DueDateForOrdering = new DateTime()
|
||||
};
|
||||
|
||||
var pageMarkdown = page.ToMarkdown();
|
||||
|
||||
var parsedPage = LocalCoursePage.ParseMarkdown(pageMarkdown);
|
||||
|
||||
parsedPage.Should().BeEquivalentTo(page);
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
using Management.Web.Shared.Semester;
|
||||
using Management.Web.Pages.Course.CourseCalendar;
|
||||
|
||||
public class MonthDetailTests
|
||||
{
|
||||
@@ -13,4 +13,4 @@ public class MonthDetailTests
|
||||
|
||||
detail.MonthName.Should().Be("February");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user