demo210525/TestLibrary/UnitTest1.cs

50 lines
1.4 KiB
C#
Raw Normal View History

2025-05-23 07:28:18 +00:00
using System;
using Library;
using NUnit.Framework;
namespace TestLibrary
{
public class Tests
{
[TestCaseSource(nameof(TestData))]
public void DataAssertTest(
TimeSpan[] startTimes,
int[] durations,
TimeSpan beginWorkingTime,
TimeSpan endWorkingTime,
int consultationTime,
string[] expected)
{
var result = Calculations.AvailablePeriods(startTimes, durations, beginWorkingTime, endWorkingTime,
consultationTime);
Assert.AreEqual(expected.Length, result.Length);
for (int i = 0; i < expected.Length; i++)
{
Assert.AreEqual(expected[i], result[i]);
}
}
public static object[] TestData = new object[]
{
new object[]
{
new TimeSpan[] { TimeSpan.FromHours(10) },
new int[] { 60 },
TimeSpan.FromHours(9),
TimeSpan.FromHours(12),
30,
new string[] { "09:00-09:30", "09:30-10:00", "11:00-11:30", "11:30-12:00" }
},
new object[]
{
new TimeSpan[] { },
new int[] { },
TimeSpan.FromHours(8),
TimeSpan.FromHours(9),
20,
new string[] { "08:00-08:20", "08:20-08:40", "08:40-09:00" }
},
};
}
}