diff --git a/Libary/bin/Debug/net8.0/Libary.dll b/Libary/bin/Debug/net8.0/Libary.dll index 071d1dc..813b5fb 100644 Binary files a/Libary/bin/Debug/net8.0/Libary.dll and b/Libary/bin/Debug/net8.0/Libary.dll differ diff --git a/Libary/bin/Debug/net8.0/Libary.pdb b/Libary/bin/Debug/net8.0/Libary.pdb index 160f1c8..e832ef7 100644 Binary files a/Libary/bin/Debug/net8.0/Libary.pdb and b/Libary/bin/Debug/net8.0/Libary.pdb differ diff --git a/Libary/obj/Debug/net8.0/Avalonia/Resources.Inputs.cache b/Libary/obj/Debug/net8.0/Avalonia/Resources.Inputs.cache index 3c2cfba..cb8fe4e 100644 --- a/Libary/obj/Debug/net8.0/Avalonia/Resources.Inputs.cache +++ b/Libary/obj/Debug/net8.0/Avalonia/Resources.Inputs.cache @@ -1 +1 @@ -131b5aa1eec61c03e0de308b53b37dda1e247446608eac3610b6abf6ac8c5f4f +8225e38577162de4c294c9082f60e297ff6031ffb0f06c48e1d165e82cf8e2d5 diff --git a/Libary/obj/Debug/net8.0/Libary.AssemblyInfo.cs b/Libary/obj/Debug/net8.0/Libary.AssemblyInfo.cs index c44eb32..5361404 100644 --- a/Libary/obj/Debug/net8.0/Libary.AssemblyInfo.cs +++ b/Libary/obj/Debug/net8.0/Libary.AssemblyInfo.cs @@ -13,7 +13,7 @@ using System.Reflection; [assembly: System.Reflection.AssemblyCompanyAttribute("Libary")] [assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")] [assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")] -[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+474cfc34bd9df61d876e8fbb651d8638dc01db9a")] +[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+4c7cd11a02cd4875b63674478b47c634ebd57f7b")] [assembly: System.Reflection.AssemblyProductAttribute("Libary")] [assembly: System.Reflection.AssemblyTitleAttribute("Libary")] [assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")] diff --git a/Libary/obj/Debug/net8.0/Libary.AssemblyInfoInputs.cache b/Libary/obj/Debug/net8.0/Libary.AssemblyInfoInputs.cache index 2032dbf..d53f93e 100644 --- a/Libary/obj/Debug/net8.0/Libary.AssemblyInfoInputs.cache +++ b/Libary/obj/Debug/net8.0/Libary.AssemblyInfoInputs.cache @@ -1 +1 @@ -5205e9b7fea8de931323c3181ca4f6ec42e7869f756c2393fb2eb5cdc694c811 +2fe973267572af8c261cd1e68ce5ce6534482530b4ed427c9c741f4f157707be diff --git a/Libary/obj/Debug/net8.0/Libary.dll b/Libary/obj/Debug/net8.0/Libary.dll index 071d1dc..813b5fb 100644 Binary files a/Libary/obj/Debug/net8.0/Libary.dll and b/Libary/obj/Debug/net8.0/Libary.dll differ diff --git a/Libary/obj/Debug/net8.0/Libary.pdb b/Libary/obj/Debug/net8.0/Libary.pdb index 160f1c8..e832ef7 100644 Binary files a/Libary/obj/Debug/net8.0/Libary.pdb and b/Libary/obj/Debug/net8.0/Libary.pdb differ diff --git a/Libary/obj/Debug/net8.0/ref/Libary.dll b/Libary/obj/Debug/net8.0/ref/Libary.dll index 67ff621..1cb5efb 100644 Binary files a/Libary/obj/Debug/net8.0/ref/Libary.dll and b/Libary/obj/Debug/net8.0/ref/Libary.dll differ diff --git a/Libary/obj/Debug/net8.0/refint/Libary.dll b/Libary/obj/Debug/net8.0/refint/Libary.dll index 67ff621..1cb5efb 100644 Binary files a/Libary/obj/Debug/net8.0/refint/Libary.dll and b/Libary/obj/Debug/net8.0/refint/Libary.dll differ diff --git a/Libary/obj/rider.project.model.nuget.info b/Libary/obj/rider.project.model.nuget.info index bfad060..e2e74f9 100644 --- a/Libary/obj/rider.project.model.nuget.info +++ b/Libary/obj/rider.project.model.nuget.info @@ -1 +1 @@ -17452715769073011 \ No newline at end of file +17453274039105030 \ No newline at end of file diff --git a/Libary/obj/rider.project.restore.info b/Libary/obj/rider.project.restore.info index bfad060..bbfdc5f 100644 --- a/Libary/obj/rider.project.restore.info +++ b/Libary/obj/rider.project.restore.info @@ -1 +1 @@ -17452715769073011 \ No newline at end of file +17453274110527519 \ No newline at end of file diff --git a/Testiks/UnitTest1.cs b/Testiks/UnitTest1.cs index 68b61bd..3fd1779 100644 --- a/Testiks/UnitTest1.cs +++ b/Testiks/UnitTest1.cs @@ -1,85 +1,167 @@ -using NUnit.Framework; -using System; using Libary; -namespace Testiks +[TestFixture] +public class AdditionalTests { - public class Tests + private Calculations calculations; + + [SetUp] + public void Setup() { - [SetUp] - public void Setup() + calculations = new Calculations(); + } + + [Test] + public void TestPeriodEndsExactlyAtWorkEnd() + { + var result = calculations.AvailablePeriods( + new TimeSpan[] { new TimeSpan(16, 0, 0) }, + new int[] { 60 }, + new TimeSpan(9, 0, 0), + new TimeSpan(17, 0, 0), + 30); + + Assert.AreEqual("09:00-09:30", result[0]); + Assert.AreEqual("15:30-16:00", result[result.Length - 1]); + } + + [Test] + public void TestPeriodStartsExactlyAtWorkBegin() + { + var result = calculations.AvailablePeriods( + new TimeSpan[] { new TimeSpan(9, 0, 0) }, + new int[] { 60 }, + new TimeSpan(9, 0, 0), + new TimeSpan(17, 0, 0), + 30); + + Assert.AreEqual("10:00-10:30", result[0]); + Assert.AreEqual("16:30-17:00", result[result.Length - 1]); + } + + [Test] + public void TestNotEnoughTimeForConsultation() + { + var result = calculations.AvailablePeriods( + new TimeSpan[] { new TimeSpan(10, 0, 0), new TimeSpan(10, 45, 0) }, + new int[] { 30, 15 }, + new TimeSpan(9, 0, 0), + new TimeSpan(11, 0, 0), + 30); + + // Only 09:00-09:30 and 09:30-10:00 should be available + Assert.AreEqual(2, result.Length); + Assert.AreEqual("09:00-09:30", result[0]); + Assert.AreEqual("09:30-10:00", result[1]); + } + + [Test] + public void TestConsultationLongerThanFreeSlot() + { + var result = calculations.AvailablePeriods( + new TimeSpan[] { new TimeSpan(10, 0, 0), new TimeSpan(11, 0, 0) }, + new int[] { 30, 30 }, + new TimeSpan(9, 0, 0), + new TimeSpan(12, 0, 0), + 45); + + // Only 09:00-09:45 and 09:45-10:30 fit + Assert.AreEqual(1, result.Length); + Assert.AreEqual("09:00-09:45", result[0]); + } + + [Test] + public void TestBusyPeriodsOverlap() + { + var result = calculations.AvailablePeriods( + new TimeSpan[] { new TimeSpan(10, 0, 0), new TimeSpan(10, 30, 0) }, + new int[] { 60, 60 }, + new TimeSpan(9, 0, 0), + new TimeSpan(12, 0, 0), + 30); + + Assert.AreEqual(new[] { - } + "09:00-09:30", + "09:30-10:00", + "11:30-12:00" + }, result); + } - [Test] - public void TestNoBusyPeriods() + [Test] + public void TestBusyEndsAtWorkEnd() + { + var result = calculations.AvailablePeriods( + new TimeSpan[] { new TimeSpan(16, 30, 0) }, + new int[] { 30 }, + new TimeSpan(9, 0, 0), + new TimeSpan(17, 0, 0), + 30); + + Assert.IsFalse(Array.Exists(result, r => r.StartsWith("16:30"))); + } + + [Test] + public void TestMultipleGapsBetweenBusy() + { + var result = calculations.AvailablePeriods( + new TimeSpan[] + { + new TimeSpan(10, 0, 0), + new TimeSpan(12, 0, 0), + new TimeSpan(14, 0, 0) + }, + new int[] { 30, 30, 30 }, + new TimeSpan(9, 0, 0), + new TimeSpan(15, 0, 0), + 30); + + Assert.AreEqual(new[] { - Calculations calculations = new Calculations(); - TimeSpan[] startTimes = Array.Empty(); - int[] durations = Array.Empty(); - TimeSpan beginWorkingTime = new TimeSpan(9, 0, 0); - TimeSpan endWorkingTime = new TimeSpan(17, 0, 0); - int consultationTime = 30; + "09:00-09:30", "09:30-10:00", + "10:30-11:00", "11:00-11:30", "11:30-12:00", + "12:30-13:00", "13:00-13:30", "13:30-14:00", + "14:30-15:00" + }, result); + } + [Test] + public void TestExactSlotAtEndOfDay() + { + var result = calculations.AvailablePeriods( + Array.Empty(), + Array.Empty(), + new TimeSpan(16, 30, 0), + new TimeSpan(17, 0, 0), + 30); - string[] result = calculations.AvailablePeriods(startTimes, durations, beginWorkingTime, endWorkingTime, - consultationTime); + Assert.AreEqual(1, result.Length); + Assert.AreEqual("16:30-17:00", result[0]); + } + [Test] + public void TestBusyCoversWholeDay() + { + var result = calculations.AvailablePeriods( + new TimeSpan[] { new TimeSpan(9, 0, 0) }, + new int[] { 480 }, + new TimeSpan(9, 0, 0), + new TimeSpan(17, 0, 0), + 30); - Assert.AreEqual(16, result.Length); - Assert.AreEqual("09:00-09:30", result[0]); - Assert.AreEqual("16:30-17:00", result[15]); - } + Assert.AreEqual(0, result.Length); + } - [Test] - public void TestSingleBusyPeriod() - { + [Test] + public void TestFreeSlotBeforeFirstBusy() + { + var result = calculations.AvailablePeriods( + new TimeSpan[] { new TimeSpan(9, 30, 0) }, + new int[] { 60 }, + new TimeSpan(9, 0, 0), + new TimeSpan(11, 0, 0), + 30); - Calculations calculations = new Calculations(); - TimeSpan[] startTimes = new TimeSpan[] { new TimeSpan(10, 0, 0) }; - int[] durations = new int[] { 60 }; - TimeSpan beginWorkingTime = new TimeSpan(9, 0, 0); - TimeSpan endWorkingTime = new TimeSpan(17, 0, 0); - int consultationTime = 30; - - - string[] result = calculations.AvailablePeriods(startTimes, durations, beginWorkingTime, endWorkingTime, - consultationTime); - - - Assert.AreEqual(14, result.Length); - Assert.AreEqual("09:00-09:30", result[0]); - Assert.AreEqual("09:30-10:00", result[1]); - Assert.AreEqual("11:00-11:30", result[2]); - Assert.AreEqual("16:30-17:00", result[13]); - } - - [Test] - public void TestMultipleBusyPeriods() - { - // Arrange - Calculations calculations = new Calculations(); - TimeSpan[] startTimes = new TimeSpan[] - { new TimeSpan(10, 0, 0), new TimeSpan(12, 0, 0), new TimeSpan(14, 0, 0) }; - int[] durations = new int[] { 60, 30, 90 }; - TimeSpan beginWorkingTime = new TimeSpan(9, 0, 0); - TimeSpan endWorkingTime = new TimeSpan(17, 0, 0); - int consultationTime = 30; - - // Act - string[] result = calculations.AvailablePeriods(startTimes, durations, beginWorkingTime, endWorkingTime, - consultationTime); - - // Assert - Assert.AreEqual(10, result.Length); - Assert.AreEqual("09:00-09:30", result[0]); - Assert.AreEqual("09:30-10:00", result[1]); - Assert.AreEqual("11:00-11:30", result[2]); - Assert.AreEqual("11:30-12:00", result[3]); - Assert.AreEqual("12:30-13:00", result[4]); - Assert.AreEqual("15:30-16:00", result[5]); - Assert.AreEqual("16:00-16:30", result[6]); - Assert.AreEqual("16:30-17:00", result[7]); - } + Assert.AreEqual(new[] { "09:00-09:30", "10:30-11:00" }, result); } } diff --git a/Testiks/bin/Debug/net8.0/Libary.dll b/Testiks/bin/Debug/net8.0/Libary.dll index 071d1dc..813b5fb 100644 Binary files a/Testiks/bin/Debug/net8.0/Libary.dll and b/Testiks/bin/Debug/net8.0/Libary.dll differ diff --git a/Testiks/bin/Debug/net8.0/Libary.pdb b/Testiks/bin/Debug/net8.0/Libary.pdb index 160f1c8..e832ef7 100644 Binary files a/Testiks/bin/Debug/net8.0/Libary.pdb and b/Testiks/bin/Debug/net8.0/Libary.pdb differ diff --git a/Testiks/bin/Debug/net8.0/Testiks.dll b/Testiks/bin/Debug/net8.0/Testiks.dll index 43c4826..ee51053 100644 Binary files a/Testiks/bin/Debug/net8.0/Testiks.dll and b/Testiks/bin/Debug/net8.0/Testiks.dll differ diff --git a/Testiks/bin/Debug/net8.0/Testiks.pdb b/Testiks/bin/Debug/net8.0/Testiks.pdb index 87a38b9..b0ce7c5 100644 Binary files a/Testiks/bin/Debug/net8.0/Testiks.pdb and b/Testiks/bin/Debug/net8.0/Testiks.pdb differ diff --git a/Testiks/obj/Debug/net8.0/Avalonia/Resources.Inputs.cache b/Testiks/obj/Debug/net8.0/Avalonia/Resources.Inputs.cache index dd6d432..45c9f7f 100644 --- a/Testiks/obj/Debug/net8.0/Avalonia/Resources.Inputs.cache +++ b/Testiks/obj/Debug/net8.0/Avalonia/Resources.Inputs.cache @@ -1 +1 @@ -385c61a74b50639bafa4b25300dc340d24650e626a384c315748f338ad795408 +48cbecb52d8ac521ed01ef74f84514cb264a4f8b19c89b08f276a19594ce5a68 diff --git a/Testiks/obj/Debug/net8.0/Testiks.AssemblyInfo.cs b/Testiks/obj/Debug/net8.0/Testiks.AssemblyInfo.cs index c176fc7..ee135c9 100644 --- a/Testiks/obj/Debug/net8.0/Testiks.AssemblyInfo.cs +++ b/Testiks/obj/Debug/net8.0/Testiks.AssemblyInfo.cs @@ -13,7 +13,7 @@ using System.Reflection; [assembly: System.Reflection.AssemblyCompanyAttribute("Testiks")] [assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")] [assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")] -[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+474cfc34bd9df61d876e8fbb651d8638dc01db9a")] +[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+4c7cd11a02cd4875b63674478b47c634ebd57f7b")] [assembly: System.Reflection.AssemblyProductAttribute("Testiks")] [assembly: System.Reflection.AssemblyTitleAttribute("Testiks")] [assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")] diff --git a/Testiks/obj/Debug/net8.0/Testiks.AssemblyInfoInputs.cache b/Testiks/obj/Debug/net8.0/Testiks.AssemblyInfoInputs.cache index 3191bd5..2ec1d65 100644 --- a/Testiks/obj/Debug/net8.0/Testiks.AssemblyInfoInputs.cache +++ b/Testiks/obj/Debug/net8.0/Testiks.AssemblyInfoInputs.cache @@ -1 +1 @@ -c4eac3649ace1954c03933ec2b649967c97dc33ff6e29422678b986131861de7 +4c80f84b28b9b30dfff81dc2a956a01ce199c01cc6a87ddd95d59bd1b4922efe diff --git a/Testiks/obj/Debug/net8.0/Testiks.csproj.AssemblyReference.cache b/Testiks/obj/Debug/net8.0/Testiks.csproj.AssemblyReference.cache index 00806e2..711cbb7 100644 Binary files a/Testiks/obj/Debug/net8.0/Testiks.csproj.AssemblyReference.cache and b/Testiks/obj/Debug/net8.0/Testiks.csproj.AssemblyReference.cache differ diff --git a/Testiks/obj/Debug/net8.0/Testiks.dll b/Testiks/obj/Debug/net8.0/Testiks.dll index 43c4826..ee51053 100644 Binary files a/Testiks/obj/Debug/net8.0/Testiks.dll and b/Testiks/obj/Debug/net8.0/Testiks.dll differ diff --git a/Testiks/obj/Debug/net8.0/Testiks.pdb b/Testiks/obj/Debug/net8.0/Testiks.pdb index 87a38b9..b0ce7c5 100644 Binary files a/Testiks/obj/Debug/net8.0/Testiks.pdb and b/Testiks/obj/Debug/net8.0/Testiks.pdb differ diff --git a/Testiks/obj/Debug/net8.0/ref/Testiks.dll b/Testiks/obj/Debug/net8.0/ref/Testiks.dll index c9dae2c..9021486 100644 Binary files a/Testiks/obj/Debug/net8.0/ref/Testiks.dll and b/Testiks/obj/Debug/net8.0/ref/Testiks.dll differ diff --git a/Testiks/obj/Debug/net8.0/refint/Testiks.dll b/Testiks/obj/Debug/net8.0/refint/Testiks.dll index c9dae2c..9021486 100644 Binary files a/Testiks/obj/Debug/net8.0/refint/Testiks.dll and b/Testiks/obj/Debug/net8.0/refint/Testiks.dll differ diff --git a/Testiks/obj/rider.project.model.nuget.info b/Testiks/obj/rider.project.model.nuget.info index 81a49f5..f55869c 100644 --- a/Testiks/obj/rider.project.model.nuget.info +++ b/Testiks/obj/rider.project.model.nuget.info @@ -1 +1 @@ -17452715790687712 \ No newline at end of file +17453274040132284 \ No newline at end of file diff --git a/Testiks/obj/rider.project.restore.info b/Testiks/obj/rider.project.restore.info index 81a49f5..cb18975 100644 --- a/Testiks/obj/rider.project.restore.info +++ b/Testiks/obj/rider.project.restore.info @@ -1 +1 @@ -17452715790687712 \ No newline at end of file +17453274110557444 \ No newline at end of file diff --git a/demo_hard.sln.DotSettings.user b/demo_hard.sln.DotSettings.user new file mode 100644 index 0000000..4b9de65 --- /dev/null +++ b/demo_hard.sln.DotSettings.user @@ -0,0 +1,4 @@ + + <SessionState ContinuousTestingMode="0" IsActive="True" Name="All tests from Solution" xmlns="urn:schemas-jetbrains-com:jetbrains-ut-session"> + <Solution /> +</SessionState> \ No newline at end of file diff --git a/demo_hard/obj/Debug/net9.0/Avalonia/Resources.Inputs.cache b/demo_hard/obj/Debug/net9.0/Avalonia/Resources.Inputs.cache index a8c66a9..54b8bba 100644 --- a/demo_hard/obj/Debug/net9.0/Avalonia/Resources.Inputs.cache +++ b/demo_hard/obj/Debug/net9.0/Avalonia/Resources.Inputs.cache @@ -1 +1 @@ -a1a313d6927bda03862de3792a717da1cb8b66b60fd436676cb5d57a9b1e725b +3563d6e7b6dca60dc93c64eb4bd7c96205b2d978d945060b2843a78ceeee26b9 diff --git a/demo_hard/obj/Debug/net9.0/demo_hard.AssemblyInfo.cs b/demo_hard/obj/Debug/net9.0/demo_hard.AssemblyInfo.cs index 732f1fe..ac92c88 100644 --- a/demo_hard/obj/Debug/net9.0/demo_hard.AssemblyInfo.cs +++ b/demo_hard/obj/Debug/net9.0/demo_hard.AssemblyInfo.cs @@ -13,7 +13,7 @@ using System.Reflection; [assembly: System.Reflection.AssemblyCompanyAttribute("demo_hard")] [assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")] [assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")] -[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+50e56467d7d10df36759130ef24997a8c6ea8a33")] +[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+4c7cd11a02cd4875b63674478b47c634ebd57f7b")] [assembly: System.Reflection.AssemblyProductAttribute("demo_hard")] [assembly: System.Reflection.AssemblyTitleAttribute("demo_hard")] [assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")] diff --git a/demo_hard/obj/Debug/net9.0/demo_hard.AssemblyInfoInputs.cache b/demo_hard/obj/Debug/net9.0/demo_hard.AssemblyInfoInputs.cache index d247535..44627c4 100644 --- a/demo_hard/obj/Debug/net9.0/demo_hard.AssemblyInfoInputs.cache +++ b/demo_hard/obj/Debug/net9.0/demo_hard.AssemblyInfoInputs.cache @@ -1 +1 @@ -d558e19871cd3b2b9f2f0170e2a01cb1d30cd37918ea9e521a55dc94c303ad3d +24d3434467a08df4b985b846f9a297233187ac8e7bc94ca6782eba1adb3f5246 diff --git a/demo_hard/obj/rider.project.model.nuget.info b/demo_hard/obj/rider.project.model.nuget.info index f6f84da..c1b4ecd 100644 --- a/demo_hard/obj/rider.project.model.nuget.info +++ b/demo_hard/obj/rider.project.model.nuget.info @@ -1 +1 @@ -17453098515261366 \ No newline at end of file +17453274051675348 \ No newline at end of file diff --git a/demo_hard/obj/rider.project.restore.info b/demo_hard/obj/rider.project.restore.info index 6a23581..2d33c63 100644 --- a/demo_hard/obj/rider.project.restore.info +++ b/demo_hard/obj/rider.project.restore.info @@ -1 +1 @@ -17453098574157962 \ No newline at end of file +17453274111175791 \ No newline at end of file