Skip to content

Commit

Permalink
new tests
Browse files Browse the repository at this point in the history
  • Loading branch information
CME64 committed Aug 26, 2021
1 parent fb269c0 commit fd8c8df
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
2 changes: 1 addition & 1 deletion WorkTimeCalculator/WorkTimeCalculator.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Time complexity: O(n*k) where n is the maximum number of shifts per day, and k i
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Version>1.0.5</Version>
<PackageTags>calculator time schedule holidays business-hours date-range shifts business-time work-time work-hours work-shifts work business hours time</PackageTags>
<PackageReleaseNotes>Description added to functions (enhanced)</PackageReleaseNotes>
<PackageReleaseNotes>ArgumentException throwing on misconfiguration</PackageReleaseNotes>
<PackageIcon>calendar.png</PackageIcon>
<PackageIconUrl />
<GenerateDocumentationFile>true</GenerateDocumentationFile>
Expand Down
29 changes: 29 additions & 0 deletions WorkTimeCalculatorTest/ConfigurationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,5 +64,34 @@ public void HolidayRangeReversed() {
var ex = Assert.Throws<ArgumentException>(() => new WorkTimeCalculator(DayShifts, Holidays));
Assert.Equal($"Holiday end preceeds the start [from {Holidays[0].Start} to {Holidays[0].End}]", ex.Message);
}

[Fact]
public void ExactPeriodRange() {
Dictionary<DayOfWeek, List<WorkShift>> DayShifts = new Dictionary<DayOfWeek, List<WorkShift>>() {
{ DayOfWeek.Sunday, new List<WorkShift>(){
new WorkShift(){ Start = new TimeSpan(0,0,0), End = new TimeSpan(24,0,0)}
} }
};

List<HolidayConfig> Holidays = new List<HolidayConfig>();
var c = new WorkTimeCalculator(DayShifts, Holidays);

Assert.NotNull(c);
}

[Fact]
public void FullDaysWork() {
Dictionary<DayOfWeek, List<WorkShift>> DayShifts = new Dictionary<DayOfWeek, List<WorkShift>>() {
{ DayOfWeek.Sunday, new List<WorkShift>(){
new WorkShift(){ Start = new TimeSpan(0,0,0), End = new TimeSpan(24,0,0)}
} }
};

List<HolidayConfig> Holidays = new List<HolidayConfig>();

var c = new WorkTimeCalculator(DayShifts, Holidays);
Assert.Equal(new TimeSpan(5,0,0), c.CalculateWorkTime(new DateTime(2021,8,1,10,0,0), new DateTime(2021, 8, 1, 15, 0, 0)));
}
}

}

0 comments on commit fd8c8df

Please sign in to comment.