From 3d39793663200564d51b9a5b97c3810d0260ed42 Mon Sep 17 00:00:00 2001 From: Thomas Malowanczyk Date: Fri, 13 Dec 2024 15:59:10 +0100 Subject: [PATCH] Add generator for DateOnly generator is limited to .net6 and above as it was introduced as part of .net6 --- .../Generators/DateOnlyGenerator.cs | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 src/Atc.Test/Customizations/Generators/DateOnlyGenerator.cs diff --git a/src/Atc.Test/Customizations/Generators/DateOnlyGenerator.cs b/src/Atc.Test/Customizations/Generators/DateOnlyGenerator.cs new file mode 100644 index 0000000..5e42365 --- /dev/null +++ b/src/Atc.Test/Customizations/Generators/DateOnlyGenerator.cs @@ -0,0 +1,22 @@ +#if NET6_0_OR_GREATER +namespace Atc.Test.Customizations.Generators; + +/// +/// Responsible for generating instances +/// that has not been canceled. +/// +[AutoRegister] +public class DateOnlyGenerator : ISpecimenBuilder +{ + /// + public object Create(object request, ISpecimenContext context) + { + if (!request.IsRequestFor()) + { + return new NoSpecimen(); + } + + return DateOnly.FromDateTime(context.Create()); + } +} +#endif \ No newline at end of file