69 lines
2.4 KiB
C#
69 lines
2.4 KiB
C#
using System;
|
|
using Xunit;
|
|
using Library;
|
|
|
|
namespace Library.Tests
|
|
{
|
|
public class CalculationsTests
|
|
{
|
|
[Fact]
|
|
public void AvailablePeriods_ReturnsFullDaySlots_WhenNoAppointments()
|
|
{
|
|
// Arrange
|
|
var 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;
|
|
|
|
// Act
|
|
var result = calculations.AvailablePeriods(startTimes, durations, beginWorkingTime, endWorkingTime, consultationTime);
|
|
|
|
// Assert
|
|
Assert.NotEmpty(result);
|
|
Assert.Contains("09:00-09:30", result);
|
|
Assert.Contains("16:30-17:00", result);
|
|
}
|
|
|
|
[Fact]
|
|
public void AvailablePeriods_ReturnsCorrectSlots_WhenThereAreAppointments()
|
|
{
|
|
// Arrange
|
|
var calculations = new Calculations();
|
|
TimeSpan[] startTimes = { new TimeSpan(10, 0, 0), new TimeSpan(14, 0, 0) };
|
|
int[] durations = { 60, 60 };
|
|
TimeSpan beginWorkingTime = new TimeSpan(9, 0, 0);
|
|
TimeSpan endWorkingTime = new TimeSpan(17, 0, 0);
|
|
int consultationTime = 30;
|
|
|
|
// Act
|
|
var result = calculations.AvailablePeriods(startTimes, durations, beginWorkingTime, endWorkingTime, consultationTime);
|
|
|
|
// Assert
|
|
Assert.DoesNotContain("10:00-10:30", result);
|
|
Assert.DoesNotContain("14:00-14:30", result);
|
|
Assert.Contains("09:00-09:30", result);
|
|
Assert.Contains("15:30-16:00", result);
|
|
}
|
|
|
|
[Fact]
|
|
public void AvailablePeriods_ReturnsEmpty_WhenNoFreeSlots()
|
|
{
|
|
// Arrange
|
|
var calculations = new Calculations();
|
|
TimeSpan[] startTimes = { new TimeSpan(9, 0, 0) };
|
|
int[] durations = { 480 }; // 8 hours (full workday)
|
|
TimeSpan beginWorkingTime = new TimeSpan(9, 0, 0);
|
|
TimeSpan endWorkingTime = new TimeSpan(17, 0, 0);
|
|
int consultationTime = 30;
|
|
|
|
// Act
|
|
var result = calculations.AvailablePeriods(startTimes, durations, beginWorkingTime, endWorkingTime, consultationTime);
|
|
|
|
// Assert
|
|
Assert.Empty(result);
|
|
}
|
|
}
|
|
}
|