sharee.bike-App/TestFramework/DateTimeMocker.cs

25 lines
600 B
C#
Raw Normal View History

2021-07-12 21:31:46 +02:00
using System;
using System.Collections.Generic;
namespace TestTINKLib
{
2022-09-06 16:08:19 +02:00
public class DateTimeMocker
{
private static int m_iIndex;
private static IList<DateTime> m_oDateTimeSeries;
2021-07-12 21:31:46 +02:00
2022-09-06 16:08:19 +02:00
public DateTimeMocker(IList<DateTime> p_oDateTimeSeries)
{
if (p_oDateTimeSeries.Count < 1)
{
throw new Exception("Can not initialize mock object. List must contain at least one date time.");
}
2021-07-12 21:31:46 +02:00
2022-09-06 16:08:19 +02:00
m_iIndex = 0;
m_oDateTimeSeries = p_oDateTimeSeries;
}
2021-07-12 21:31:46 +02:00
2022-09-06 16:08:19 +02:00
public Func<DateTime> GetDateTime = () => m_oDateTimeSeries[m_iIndex < m_oDateTimeSeries.Count ? m_iIndex++ : m_iIndex = 0];
}
2021-07-12 21:31:46 +02:00
}