From fd8c8df428440a2e8b34810d6c14cde99e273197 Mon Sep 17 00:00:00 2001 From: "Mohammed I. Alsayed" Date: Thu, 26 Aug 2021 10:09:11 +0300 Subject: [PATCH] new tests --- WorkTimeCalculator/WorkTimeCalculator.csproj | 2 +- WorkTimeCalculatorTest/ConfigurationTests.cs | 29 ++++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/WorkTimeCalculator/WorkTimeCalculator.csproj b/WorkTimeCalculator/WorkTimeCalculator.csproj index 3bfda7f..650f96d 100644 --- a/WorkTimeCalculator/WorkTimeCalculator.csproj +++ b/WorkTimeCalculator/WorkTimeCalculator.csproj @@ -15,7 +15,7 @@ Time complexity: O(n*k) where n is the maximum number of shifts per day, and k i true 1.0.5 calculator time schedule holidays business-hours date-range shifts business-time work-time work-hours work-shifts work business hours time - Description added to functions (enhanced) + ArgumentException throwing on misconfiguration calendar.png true diff --git a/WorkTimeCalculatorTest/ConfigurationTests.cs b/WorkTimeCalculatorTest/ConfigurationTests.cs index b7ef214..5fb9a60 100644 --- a/WorkTimeCalculatorTest/ConfigurationTests.cs +++ b/WorkTimeCalculatorTest/ConfigurationTests.cs @@ -64,5 +64,34 @@ public void HolidayRangeReversed() { var ex = Assert.Throws(() => 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> DayShifts = new Dictionary>() { + { DayOfWeek.Sunday, new List(){ + new WorkShift(){ Start = new TimeSpan(0,0,0), End = new TimeSpan(24,0,0)} + } } + }; + + List Holidays = new List(); + var c = new WorkTimeCalculator(DayShifts, Holidays); + + Assert.NotNull(c); + } + + [Fact] + public void FullDaysWork() { + Dictionary> DayShifts = new Dictionary>() { + { DayOfWeek.Sunday, new List(){ + new WorkShift(){ Start = new TimeSpan(0,0,0), End = new TimeSpan(24,0,0)} + } } + }; + + List Holidays = new List(); + + 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))); + } } + }