mirror of
https://github.com/alexmickelson/canvasManagement.git
synced 2026-03-25 23:28:33 -06:00
can create config from semester
This commit is contained in:
24
Management.Test/Features/ConfigurationTests.cs
Normal file
24
Management.Test/Features/ConfigurationTests.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
using CanvasModel.EnrollmentTerms;
|
||||
|
||||
public class ConfigurationTests
|
||||
{
|
||||
[Test]
|
||||
public void TestCanCreateConfigFromTermAndDays()
|
||||
{
|
||||
|
||||
DateTime startAt = new DateTime(2022, 1, 1);
|
||||
DateTime endAt = new DateTime(2022, 1, 2);
|
||||
var canvasTerm = new EnrollmentTermModel(
|
||||
Id: 1,
|
||||
Name: "one",
|
||||
StartAt: startAt,
|
||||
EndAt: endAt
|
||||
);
|
||||
var daysOfWeek = new DayOfWeek[] { DayOfWeek.Monday };
|
||||
|
||||
var config = ConfigurationManagement.CreateFromTerm(canvasTerm, daysOfWeek);
|
||||
config.StartDate.Should().Be(startAt);
|
||||
config.EndDate.Should().Be(endAt);
|
||||
config.Days.Should().BeEquivalentTo(daysOfWeek);
|
||||
}
|
||||
}
|
||||
@@ -5,8 +5,6 @@ public class SemesterPlanner
|
||||
public IEnumerable<CalendarMonth> Months { get; }
|
||||
public SemesterPlanner(SemesterConfiguration configuration)
|
||||
{
|
||||
// var start = configuration.StartAt ?? throw new Exception($"Canvas Term must have a start date. Term: {configuration.Id}");
|
||||
// var end = configuration.EndAt ?? throw new Exception($"Canvas Term must have a end date. Term: {configuration.Id}");
|
||||
var start = configuration.StartDate;
|
||||
var end = configuration.EndDate;
|
||||
|
||||
|
||||
19
Management/Features/Configuration/ConfigrationManagement.cs
Normal file
19
Management/Features/Configuration/ConfigrationManagement.cs
Normal file
@@ -0,0 +1,19 @@
|
||||
using CanvasModel.EnrollmentTerms;
|
||||
|
||||
public class ConfigurationManagement
|
||||
{
|
||||
public static SemesterConfiguration CreateFromTerm(
|
||||
EnrollmentTermModel canvasTerm,
|
||||
DayOfWeek[] daysOfWeek
|
||||
)
|
||||
{
|
||||
var start = canvasTerm.StartAt ?? throw new Exception($"Canvas Term must have a start date. Term: {canvasTerm.Name}");
|
||||
var end = canvasTerm.EndAt ?? throw new Exception($"Canvas Term must have a end date. Term: {canvasTerm.Name}");
|
||||
|
||||
return new SemesterConfiguration(
|
||||
StartDate: start,
|
||||
EndDate: end,
|
||||
Days: daysOfWeek
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user