Сообщение: System.ArgumentOutOfRangeException: параметры Hour, Minute и
Second описывают непредставимое DateTime.
Трассировка стека: TimeOnly.ctor(Int32 час, Int32 минута)
RuntimeMethodHandle.InvokeMethod(цель объекта, аргументы Void**,
Signature sig, Boolean isConstructor)
MethodBaseInvoker.InvokeDirectByRefWithFewArgs(Object obj, Span`1
copyOfArgs, BindingFlags ignoreAttr)
. Пример:
Код: Выделить всё
public class Plan
{
public DateOnly Date { get; set; }
public TimeOnly StartTime { get; set; }
public TimeOnly EndTime { get; set; }
public Guid EmployeeId { get; set; }
}
public class Employee
{
public ICollection
? Plans { get; set; }
}
[Fact]
private async Task Handle_ShiftServiceTests_Valid()
{
var shifts = new AutoFaker()
.RuleFor(x => x.Date, new DateOnly(2025, 03, 1))
.RuleFor(x => x.StartTime, TimeOnly.FromDateTime(DateTime.Now))
.RuleFor(x => x.EndTime, TimeOnly.FromDateTime(DateTime.Now))
.Generate(1);
var worker = new AutoFaker()
.RuleFor(a => a.plans, shifts)
.Generate();
}
Подробнее здесь: https://stackoverflow.com/questions/793 ... e-datetime