testiki
This commit is contained in:
parent
4c7cd11a02
commit
cbe1e192f4
Binary file not shown.
Binary file not shown.
@ -1 +1 @@
|
||||
131b5aa1eec61c03e0de308b53b37dda1e247446608eac3610b6abf6ac8c5f4f
|
||||
8225e38577162de4c294c9082f60e297ff6031ffb0f06c48e1d165e82cf8e2d5
|
||||
|
@ -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")]
|
||||
|
@ -1 +1 @@
|
||||
5205e9b7fea8de931323c3181ca4f6ec42e7869f756c2393fb2eb5cdc694c811
|
||||
2fe973267572af8c261cd1e68ce5ce6534482530b4ed427c9c741f4f157707be
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1 +1 @@
|
||||
17452715769073011
|
||||
17453274039105030
|
@ -1 +1 @@
|
||||
17452715769073011
|
||||
17453274110527519
|
@ -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<TimeSpan>();
|
||||
int[] durations = Array.Empty<int>();
|
||||
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<TimeSpan>(),
|
||||
Array.Empty<int>(),
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1 +1 @@
|
||||
385c61a74b50639bafa4b25300dc340d24650e626a384c315748f338ad795408
|
||||
48cbecb52d8ac521ed01ef74f84514cb264a4f8b19c89b08f276a19594ce5a68
|
||||
|
@ -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")]
|
||||
|
@ -1 +1 @@
|
||||
c4eac3649ace1954c03933ec2b649967c97dc33ff6e29422678b986131861de7
|
||||
4c80f84b28b9b30dfff81dc2a956a01ce199c01cc6a87ddd95d59bd1b4922efe
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1 +1 @@
|
||||
17452715790687712
|
||||
17453274040132284
|
@ -1 +1 @@
|
||||
17452715790687712
|
||||
17453274110557444
|
4
demo_hard.sln.DotSettings.user
Normal file
4
demo_hard.sln.DotSettings.user
Normal file
@ -0,0 +1,4 @@
|
||||
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
|
||||
<s:String x:Key="/Default/Environment/UnitTesting/UnitTestSessionStore/Sessions/=3ba4b348_002Dcbea_002D4618_002Daed8_002D9089719c2a99/@EntryIndexedValue"><SessionState ContinuousTestingMode="0" IsActive="True" Name="All tests from Solution" xmlns="urn:schemas-jetbrains-com:jetbrains-ut-session">
|
||||
<Solution />
|
||||
</SessionState></s:String></wpf:ResourceDictionary>
|
@ -1 +1 @@
|
||||
a1a313d6927bda03862de3792a717da1cb8b66b60fd436676cb5d57a9b1e725b
|
||||
3563d6e7b6dca60dc93c64eb4bd7c96205b2d978d945060b2843a78ceeee26b9
|
||||
|
@ -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")]
|
||||
|
@ -1 +1 @@
|
||||
d558e19871cd3b2b9f2f0170e2a01cb1d30cd37918ea9e521a55dc94c303ad3d
|
||||
24d3434467a08df4b985b846f9a297233187ac8e7bc94ca6782eba1adb3f5246
|
||||
|
@ -1 +1 @@
|
||||
17453098515261366
|
||||
17453274051675348
|
@ -1 +1 @@
|
||||
17453098574157962
|
||||
17453274111175791
|
Loading…
Reference in New Issue
Block a user