From 07eb12414a4535dacfd5f18705e57b429fd3760c Mon Sep 17 00:00:00 2001 From: "D. Moonfire" Date: Sat, 21 Jan 2023 01:52:52 -0600 Subject: [PATCH] refactor(temporal)!: renamed Timekeeper to TimeService --- .../CreateCalender.cs | 4 +- .../ApplySchedules.cs | 10 ++--- .../ISchedule.cs | 4 +- .../IndexedPathRegexSchedule.cs | 4 +- .../IndexedSchedule.cs | 6 +-- .../PathRegexScheduleBase.cs | 6 +-- .../PeriodicPathRegexSchedule.cs | 6 +-- .../README.md | 4 +- .../SimplePathSchedule.cs | 6 +-- .../Validators/ApplySchedulesValidator.cs | 2 +- .../Cli/DatePipelineCommandOption.cs | 14 +++---- .../Cli/ExpiresPipelineCommandOption.cs | 4 +- .../CreateDateIndexes.cs | 10 ++--- .../FilterOutExpiredInstant.cs | 10 ++--- .../FilterOutFutureInstant.cs | 8 ++-- .../MfGames.Nitride.Temporal.csproj | 18 ++++----- .../SetInstantFromComponent.cs | 5 ++- .../SetInstantFromPath.cs | 16 +++----- .../Setup/NitrideTemporalBuilderExtensions.cs | 10 ++--- .../Setup/NitrideTemporalModule.cs | 2 +- .../{Timekeeper.cs => TimeService.cs} | 4 +- .../Validators/CreateDateIndexesValidator.cs | 2 +- .../FilterOutExpiredInstantValidator.cs | 2 +- .../FilterOutFutureInstantValidator.cs | 2 +- .../IndexedPathRegexScheduleTest.cs | 6 +-- .../PeriodicPathRegexScheduleTest.cs | 8 ++-- .../CreateDateIndexesTests.cs | 40 +++++++++---------- .../FilterOutFutureInstantTests.cs | 8 ++-- 28 files changed, 108 insertions(+), 113 deletions(-) rename src/MfGames.Nitride.Temporal/{Timekeeper.cs => TimeService.cs} (98%) diff --git a/src/MfGames.Nitride.Calendar/CreateCalender.cs b/src/MfGames.Nitride.Calendar/CreateCalender.cs index db1dd21..78294bd 100644 --- a/src/MfGames.Nitride.Calendar/CreateCalender.cs +++ b/src/MfGames.Nitride.Calendar/CreateCalender.cs @@ -28,13 +28,13 @@ namespace MfGames.Nitride.Calendar; [WithProperties] public partial class CreateCalender : OperationBase { - private readonly Timekeeper clock; + private readonly TimeService clock; private readonly IValidator validator; public CreateCalender( IValidator validator, - Timekeeper clock) + TimeService clock) { this.validator = validator; this.clock = clock; diff --git a/src/MfGames.Nitride.Temporal.Schedules/ApplySchedules.cs b/src/MfGames.Nitride.Temporal.Schedules/ApplySchedules.cs index 25df83c..63f313a 100644 --- a/src/MfGames.Nitride.Temporal.Schedules/ApplySchedules.cs +++ b/src/MfGames.Nitride.Temporal.Schedules/ApplySchedules.cs @@ -20,9 +20,9 @@ public partial class ApplySchedules : OperationBase public ApplySchedules( IValidator validator, - Timekeeper timekeeper) + TimeService timeService) { - this.Timekeeper = timekeeper; + this.TimeService = timeService; this.validator = validator; } @@ -35,9 +35,9 @@ public partial class ApplySchedules : OperationBase public Func?>? GetSchedules { get; set; } /// - /// Gets or sets the timekeeper associated with this operation. + /// Gets or sets the time service associated with this operation. /// - public Timekeeper Timekeeper { get; set; } + public TimeService TimeService { get; set; } /// public override IEnumerable Run( @@ -79,7 +79,7 @@ public partial class ApplySchedules : OperationBase continue; } - entity = schedule.Apply(entity, this.Timekeeper); + entity = schedule.Apply(entity, this.TimeService); } return entity; diff --git a/src/MfGames.Nitride.Temporal.Schedules/ISchedule.cs b/src/MfGames.Nitride.Temporal.Schedules/ISchedule.cs index a1fa15b..e8ea608 100644 --- a/src/MfGames.Nitride.Temporal.Schedules/ISchedule.cs +++ b/src/MfGames.Nitride.Temporal.Schedules/ISchedule.cs @@ -12,14 +12,14 @@ public interface ISchedule /// Applies the schedule changes to the entity and returns the results. /// /// The entity to update. - /// The timekeeper for apply. + /// The service to use for time. /// /// The modified entity, if the changes can be applied, otherwise the same /// entity. /// Entity Apply( Entity entity, - Timekeeper timekeeper); + TimeService timeService); /// /// Determines if a schedule applies to a given entity. diff --git a/src/MfGames.Nitride.Temporal.Schedules/IndexedPathRegexSchedule.cs b/src/MfGames.Nitride.Temporal.Schedules/IndexedPathRegexSchedule.cs index 8174418..954b700 100644 --- a/src/MfGames.Nitride.Temporal.Schedules/IndexedPathRegexSchedule.cs +++ b/src/MfGames.Nitride.Temporal.Schedules/IndexedPathRegexSchedule.cs @@ -34,7 +34,7 @@ public partial class IndexedPathRegexSchedule : PathRegexScheduleBase protected override Entity Apply( Entity entity, int number, - Timekeeper timekeeper) + TimeService timeService) { // Figure out the entry in the index. var applicableKeys = this.Indexes.Keys @@ -52,6 +52,6 @@ public partial class IndexedPathRegexSchedule : PathRegexScheduleBase // Pass everything into the schedule to perform the applying. int startOffset = number - startIndex; - return schedule.Apply(entity, startOffset, timekeeper); + return schedule.Apply(entity, startOffset, timeService); } } diff --git a/src/MfGames.Nitride.Temporal.Schedules/IndexedSchedule.cs b/src/MfGames.Nitride.Temporal.Schedules/IndexedSchedule.cs index e67c20a..5334dfa 100644 --- a/src/MfGames.Nitride.Temporal.Schedules/IndexedSchedule.cs +++ b/src/MfGames.Nitride.Temporal.Schedules/IndexedSchedule.cs @@ -42,7 +42,7 @@ public partial class IndexedSchedule public virtual Entity Apply( Entity entity, int number, - Timekeeper timekeeper) + TimeService timeService) { // If we have a "never", then we skip it. TimeSpan? period = this.SchedulePeriodTimeSpan; @@ -55,10 +55,10 @@ public partial class IndexedSchedule // Figure out the time from the start. DateTime when = start.Value + period.Value * number; - Instant instant = timekeeper.CreateInstant(when); + Instant instant = timeService.CreateInstant(when); // If the time hasn't past, then we don't apply it. - Instant now = timekeeper.Clock.GetCurrentInstant(); + Instant now = timeService.Clock.GetCurrentInstant(); return instant > now ? entity diff --git a/src/MfGames.Nitride.Temporal.Schedules/PathRegexScheduleBase.cs b/src/MfGames.Nitride.Temporal.Schedules/PathRegexScheduleBase.cs index 20ff381..c17dc3b 100644 --- a/src/MfGames.Nitride.Temporal.Schedules/PathRegexScheduleBase.cs +++ b/src/MfGames.Nitride.Temporal.Schedules/PathRegexScheduleBase.cs @@ -47,7 +47,7 @@ public abstract partial class PathRegexScheduleBase : ISchedule /// public virtual Entity Apply( Entity entity, - Timekeeper timekeeper) + TimeService timeService) { // Get the path and match it. string path = this.GetPath(entity); @@ -83,7 +83,7 @@ public abstract partial class PathRegexScheduleBase : ISchedule number += this.CaptureOffset; // Pass it onto the extending class. - return this.Apply(entity, number, timekeeper); + return this.Apply(entity, number, timeService); } /// @@ -107,7 +107,7 @@ public abstract partial class PathRegexScheduleBase : ISchedule protected abstract Entity Apply( Entity entity, int number, - Timekeeper timekeeper); + TimeService timeService); private Regex? GetRegex() { diff --git a/src/MfGames.Nitride.Temporal.Schedules/PeriodicPathRegexSchedule.cs b/src/MfGames.Nitride.Temporal.Schedules/PeriodicPathRegexSchedule.cs index 34a2945..0f597d0 100644 --- a/src/MfGames.Nitride.Temporal.Schedules/PeriodicPathRegexSchedule.cs +++ b/src/MfGames.Nitride.Temporal.Schedules/PeriodicPathRegexSchedule.cs @@ -49,7 +49,7 @@ public partial class PeriodicPathRegexSchedule : PathRegexScheduleBase protected override Entity Apply( Entity entity, int number, - Timekeeper timekeeper) + TimeService timeService) { // If we have a "never", then we skip it. TimeSpan? period = this.SchedulePeriodTimeSpan; @@ -62,10 +62,10 @@ public partial class PeriodicPathRegexSchedule : PathRegexScheduleBase // Figure out the time from the start. DateTime when = start.Value + period.Value * number; - Instant instant = timekeeper.CreateInstant(when); + Instant instant = timeService.CreateInstant(when); // If the time hasn't past, then we don't apply it. - Instant now = timekeeper.Clock.GetCurrentInstant(); + Instant now = timeService.Clock.GetCurrentInstant(); return instant > now ? entity diff --git a/src/MfGames.Nitride.Temporal.Schedules/README.md b/src/MfGames.Nitride.Temporal.Schedules/README.md index f044263..cf0b189 100644 --- a/src/MfGames.Nitride.Temporal.Schedules/README.md +++ b/src/MfGames.Nitride.Temporal.Schedules/README.md @@ -10,7 +10,7 @@ date (as provided by the `MfGames.Nitride.Temporal` package). A schedule is not needed when the date is in the path or inside a component. Using `MfGames.Nitride.Temporal.SetFromComponent` or `MfGames.Nitride.Temporal.SetFromPath` would be more than sufficient. This is for dynamically changing entities based on -the date based on `Timekeeper`. +the date based on `TimeService`. ## Configuring @@ -53,7 +53,7 @@ The following properties are available (along with their corresponding `With*` m - `IList Schedules` - Contains the list of schedules to apply against entities. - Defaults to an empty list. -- `Timekeeper Timekeeper` +- `TimeService TimeService` - Used to determine when the site is being generated. - Defaults to the one provided by `MfGames.Nitride.Temporal`. diff --git a/src/MfGames.Nitride.Temporal.Schedules/SimplePathSchedule.cs b/src/MfGames.Nitride.Temporal.Schedules/SimplePathSchedule.cs index 1d23030..779d6a0 100644 --- a/src/MfGames.Nitride.Temporal.Schedules/SimplePathSchedule.cs +++ b/src/MfGames.Nitride.Temporal.Schedules/SimplePathSchedule.cs @@ -21,15 +21,15 @@ public partial class SimplePathSchedule : ISchedule /// public virtual Entity Apply( Entity entity, - Timekeeper timekeeper) + TimeService timeService) { DateTime start = this.ScheduleStart ?? throw new NullReferenceException( "Cannot use a schedule without a start date."); - Instant instant = timekeeper.CreateInstant(start); + Instant instant = timeService.CreateInstant(start); // If the time hasn't past, then we don't apply it. - Instant now = timekeeper.Clock.GetCurrentInstant(); + Instant now = timeService.Clock.GetCurrentInstant(); return instant > now ? entity diff --git a/src/MfGames.Nitride.Temporal.Schedules/Validators/ApplySchedulesValidator.cs b/src/MfGames.Nitride.Temporal.Schedules/Validators/ApplySchedulesValidator.cs index f1fe2de..1ab1cd5 100644 --- a/src/MfGames.Nitride.Temporal.Schedules/Validators/ApplySchedulesValidator.cs +++ b/src/MfGames.Nitride.Temporal.Schedules/Validators/ApplySchedulesValidator.cs @@ -9,7 +9,7 @@ public class ApplySchedulesValidator : AbstractValidator this.RuleFor(x => x.GetSchedules) .NotNull(); - this.RuleFor(x => x.Timekeeper) + this.RuleFor(x => x.TimeService) .NotNull(); } } diff --git a/src/MfGames.Nitride.Temporal/Cli/DatePipelineCommandOption.cs b/src/MfGames.Nitride.Temporal/Cli/DatePipelineCommandOption.cs index 314ff44..5a14daa 100644 --- a/src/MfGames.Nitride.Temporal/Cli/DatePipelineCommandOption.cs +++ b/src/MfGames.Nitride.Temporal/Cli/DatePipelineCommandOption.cs @@ -20,14 +20,14 @@ public class DatePipelineCommandOption : IPipelineCommandOption { private readonly ILogger logger; - private readonly Timekeeper timekeeper; + private readonly TimeService timeService; public DatePipelineCommandOption( ILogger logger, - Timekeeper timekeeper) + TimeService timeService) { this.logger = logger.ForContext(); - this.timekeeper = timekeeper; + this.timeService = timeService; this.Option = new Option("--date") { @@ -53,15 +53,15 @@ public class DatePipelineCommandOption : IPipelineCommandOption // date for the entire run. var local = LocalDateTime.FromDateTime(value.Value); ZonedDateTime zoned = - local.InZoneStrictly(this.timekeeper.DateTimeZone); + local.InZoneStrictly(this.timeService.DateTimeZone); var instant = zoned.ToInstant(); - this.timekeeper.Clock = new FakeClock(instant); + this.timeService.Clock = new FakeClock(instant); } // Report the date we are processing. - Instant now = this.timekeeper.Clock.GetCurrentInstant(); - ZonedDateTime dateTime = now.InZone(this.timekeeper.DateTimeZone); + Instant now = this.timeService.Clock.GetCurrentInstant(); + ZonedDateTime dateTime = now.InZone(this.timeService.DateTimeZone); string formatted = dateTime.ToString("G", CultureInfo.InvariantCulture); this.logger.Information("Setting date/time to {When:l}", formatted); diff --git a/src/MfGames.Nitride.Temporal/Cli/ExpiresPipelineCommandOption.cs b/src/MfGames.Nitride.Temporal/Cli/ExpiresPipelineCommandOption.cs index b48a0fa..dae9267 100644 --- a/src/MfGames.Nitride.Temporal/Cli/ExpiresPipelineCommandOption.cs +++ b/src/MfGames.Nitride.Temporal/Cli/ExpiresPipelineCommandOption.cs @@ -18,13 +18,13 @@ namespace MfGames.Nitride.Temporal.Cli; /// public class ExpiresPipelineCommandOption : IPipelineCommandOption { - private readonly Timekeeper clock; + private readonly TimeService clock; private readonly ILogger logger; public ExpiresPipelineCommandOption( ILogger logger, - Timekeeper clock, + TimeService clock, string? defaultValue = null) { this.logger = logger.ForContext(); diff --git a/src/MfGames.Nitride.Temporal/CreateDateIndexes.cs b/src/MfGames.Nitride.Temporal/CreateDateIndexes.cs index 15e243b..bfc32a0 100644 --- a/src/MfGames.Nitride.Temporal/CreateDateIndexes.cs +++ b/src/MfGames.Nitride.Temporal/CreateDateIndexes.cs @@ -25,10 +25,10 @@ public partial class CreateDateIndexes : OperationBase, IResolvingOperation public CreateDateIndexes( IValidator validator, - Timekeeper timekeeper) + TimeService timeService) { this.validator = validator; - this.Timekeeper = timekeeper; + this.TimeService = timeService; } /// @@ -51,7 +51,7 @@ public partial class CreateDateIndexes : OperationBase, IResolvingOperation /// public int LessThanEqualCollapse { get; set; } - public Timekeeper Timekeeper { get; } + public TimeService TimeService { get; } /// public override IEnumerable Run( @@ -136,7 +136,7 @@ public partial class CreateDateIndexes : OperationBase, IResolvingOperation Entity? first = pair.Value[0]; - string? nextKey = this.Timekeeper + string? nextKey = this.TimeService .ToDateTime(first.Get()) .ToString(this.Formats[i + 1]); @@ -166,7 +166,7 @@ public partial class CreateDateIndexes : OperationBase, IResolvingOperation List>> grouped, Entity entity) { - var dateTime = this.Timekeeper.ToDateTime(instant); + var dateTime = this.TimeService.ToDateTime(instant); for (int i = 0; i < this.Formats.Count; i++) { diff --git a/src/MfGames.Nitride.Temporal/FilterOutExpiredInstant.cs b/src/MfGames.Nitride.Temporal/FilterOutExpiredInstant.cs index 8b2deca..2211344 100644 --- a/src/MfGames.Nitride.Temporal/FilterOutExpiredInstant.cs +++ b/src/MfGames.Nitride.Temporal/FilterOutExpiredInstant.cs @@ -20,13 +20,13 @@ public partial class FilterOutExpiredInstant : OperationBase public FilterOutExpiredInstant( IValidator validator, - Timekeeper clock) + TimeService clock) { this.validator = validator; - this.Timekeeper = clock; + this.TimeService = clock; } - public Timekeeper Timekeeper { get; set; } + public TimeService TimeService { get; set; } /// public override IEnumerable Run( @@ -35,7 +35,7 @@ public partial class FilterOutExpiredInstant : OperationBase { this.validator.ValidateAndThrow(this); - if (!this.Timekeeper.Expiration.HasValue) + if (!this.TimeService.Expiration.HasValue) { return input; } @@ -48,7 +48,7 @@ public partial class FilterOutExpiredInstant : OperationBase Instant instant, CanExpire _) { - Instant expiration = this.Timekeeper.Expiration!.Value; + Instant expiration = this.TimeService.Expiration!.Value; bool isExpired = instant.CompareTo(expiration) < 0; return isExpired ? null : entity; diff --git a/src/MfGames.Nitride.Temporal/FilterOutFutureInstant.cs b/src/MfGames.Nitride.Temporal/FilterOutFutureInstant.cs index 9df0ae0..fb7ecb5 100644 --- a/src/MfGames.Nitride.Temporal/FilterOutFutureInstant.cs +++ b/src/MfGames.Nitride.Temporal/FilterOutFutureInstant.cs @@ -15,19 +15,19 @@ namespace MfGames.Nitride.Temporal; [WithProperties] public partial class FilterOutFutureInstant : OperationBase { - public FilterOutFutureInstant(Timekeeper timekeeper) + public FilterOutFutureInstant(TimeService timeService) { - this.Timekeeper = timekeeper; + this.TimeService = timeService; } - public Timekeeper Timekeeper { get; set; } + public TimeService TimeService { get; set; } /// public override IEnumerable Run( IEnumerable input, CancellationToken cancellationToken = default) { - Instant now = this.Timekeeper.Clock.GetCurrentInstant(); + Instant now = this.TimeService.Clock.GetCurrentInstant(); return input .SelectEntity( diff --git a/src/MfGames.Nitride.Temporal/MfGames.Nitride.Temporal.csproj b/src/MfGames.Nitride.Temporal/MfGames.Nitride.Temporal.csproj index 0bb52ff..1f29e72 100644 --- a/src/MfGames.Nitride.Temporal/MfGames.Nitride.Temporal.csproj +++ b/src/MfGames.Nitride.Temporal/MfGames.Nitride.Temporal.csproj @@ -10,18 +10,18 @@ - - - - - - - - + + + + + + + + - + diff --git a/src/MfGames.Nitride.Temporal/SetInstantFromComponent.cs b/src/MfGames.Nitride.Temporal/SetInstantFromComponent.cs index 8c996f0..ca6c80c 100644 --- a/src/MfGames.Nitride.Temporal/SetInstantFromComponent.cs +++ b/src/MfGames.Nitride.Temporal/SetInstantFromComponent.cs @@ -17,11 +17,11 @@ namespace MfGames.Nitride.Temporal; /// public class SetInstantFromComponent : OperationBase { - private readonly Timekeeper clock; + private readonly TimeService clock; private readonly IValidator> validator; - public SetInstantFromComponent(Timekeeper clock) + public SetInstantFromComponent(TimeService clock) { // TODO: Figure out why Autofac won't let us register IValidator of generic classes. this.validator = new SetInstantFromComponentValidator(); @@ -73,6 +73,7 @@ public class SetInstantFromComponent : OperationBase { case null: return entity; + case Instant direct: instant = direct; diff --git a/src/MfGames.Nitride.Temporal/SetInstantFromPath.cs b/src/MfGames.Nitride.Temporal/SetInstantFromPath.cs index 0fea943..cf89036 100644 --- a/src/MfGames.Nitride.Temporal/SetInstantFromPath.cs +++ b/src/MfGames.Nitride.Temporal/SetInstantFromPath.cs @@ -23,13 +23,13 @@ namespace MfGames.Nitride.Temporal; [WithProperties] public partial class SetInstantFromPath : OperationBase { - private readonly Timekeeper clock; + private readonly TimeService clock; private readonly IValidator validator; public SetInstantFromPath( IValidator validator, - Timekeeper clock) + TimeService clock) { this.validator = validator; this.clock = clock; @@ -67,15 +67,9 @@ public partial class SetInstantFromPath : OperationBase // Create an Instant from this. Instant instant = this.clock.CreateInstant( - Convert.ToInt32( - match.Groups["year"] - .Value), - Convert.ToInt32( - match.Groups["month"] - .Value), - Convert.ToInt32( - match.Groups["day"] - .Value)); + Convert.ToInt32(match.Groups["year"].Value), + Convert.ToInt32(match.Groups["month"].Value), + Convert.ToInt32(match.Groups["day"].Value)); return entity.Set(instant); } diff --git a/src/MfGames.Nitride.Temporal/Setup/NitrideTemporalBuilderExtensions.cs b/src/MfGames.Nitride.Temporal/Setup/NitrideTemporalBuilderExtensions.cs index 15dae22..e6757fb 100644 --- a/src/MfGames.Nitride.Temporal/Setup/NitrideTemporalBuilderExtensions.cs +++ b/src/MfGames.Nitride.Temporal/Setup/NitrideTemporalBuilderExtensions.cs @@ -45,8 +45,8 @@ public static class NitrideTemporalBuilderExtensions context => { ILogger logger = context.Resolve(); - Timekeeper - clock = context.Resolve(); + TimeService + clock = context.Resolve(); return new ExpiresPipelineCommandOption( logger, @@ -65,12 +65,12 @@ public static class NitrideTemporalBuilderExtensions scope) => { ILogger logger = scope.Resolve(); - Timekeeper timekeeper = scope.Resolve(); + TimeService timeService = scope.Resolve(); - timekeeper.DateTimeZone = config.DateTimeZone; + timeService.DateTimeZone = config.DateTimeZone; logger.Verbose( "Setting time zone to {Zone:l}", - timekeeper.DateTimeZone); + timeService.DateTimeZone); }); } diff --git a/src/MfGames.Nitride.Temporal/Setup/NitrideTemporalModule.cs b/src/MfGames.Nitride.Temporal/Setup/NitrideTemporalModule.cs index e27c746..8cc198e 100644 --- a/src/MfGames.Nitride.Temporal/Setup/NitrideTemporalModule.cs +++ b/src/MfGames.Nitride.Temporal/Setup/NitrideTemporalModule.cs @@ -10,7 +10,7 @@ public class NitrideTemporalModule : Module builder.RegisterOperators(this); builder.RegisterValidators(this); - builder.RegisterType() + builder.RegisterType() .AsSelf() .SingleInstance(); diff --git a/src/MfGames.Nitride.Temporal/Timekeeper.cs b/src/MfGames.Nitride.Temporal/TimeService.cs similarity index 98% rename from src/MfGames.Nitride.Temporal/Timekeeper.cs rename to src/MfGames.Nitride.Temporal/TimeService.cs index 54064d4..3d30142 100644 --- a/src/MfGames.Nitride.Temporal/Timekeeper.cs +++ b/src/MfGames.Nitride.Temporal/TimeService.cs @@ -10,9 +10,9 @@ namespace MfGames.Nitride.Temporal; /// the desire time zone along with various methods for processing parsed /// DateTime objects into NodaTime.Instant. /// -public class Timekeeper +public class TimeService { - public Timekeeper() + public TimeService() { // We use FakeClock because we don't want time to advance in the // middle of running, just in case we are just a few seconds before diff --git a/src/MfGames.Nitride.Temporal/Validators/CreateDateIndexesValidator.cs b/src/MfGames.Nitride.Temporal/Validators/CreateDateIndexesValidator.cs index dc71ae2..15676e0 100644 --- a/src/MfGames.Nitride.Temporal/Validators/CreateDateIndexesValidator.cs +++ b/src/MfGames.Nitride.Temporal/Validators/CreateDateIndexesValidator.cs @@ -6,7 +6,7 @@ public class CreateDateIndexesValidator : AbstractValidator { public CreateDateIndexesValidator() { - this.RuleFor(a => a.Timekeeper) + this.RuleFor(a => a.TimeService) .NotNull(); this.RuleFor(a => a.CreateIndex) diff --git a/src/MfGames.Nitride.Temporal/Validators/FilterOutExpiredInstantValidator.cs b/src/MfGames.Nitride.Temporal/Validators/FilterOutExpiredInstantValidator.cs index 3b873ba..cd84c00 100644 --- a/src/MfGames.Nitride.Temporal/Validators/FilterOutExpiredInstantValidator.cs +++ b/src/MfGames.Nitride.Temporal/Validators/FilterOutExpiredInstantValidator.cs @@ -7,7 +7,7 @@ public class FilterOutExpiredInstantValidator { public FilterOutExpiredInstantValidator() { - this.RuleFor(x => x.Timekeeper) + this.RuleFor(x => x.TimeService) .NotNull(); } } diff --git a/src/MfGames.Nitride.Temporal/Validators/FilterOutFutureInstantValidator.cs b/src/MfGames.Nitride.Temporal/Validators/FilterOutFutureInstantValidator.cs index cf8da02..c50d7a5 100644 --- a/src/MfGames.Nitride.Temporal/Validators/FilterOutFutureInstantValidator.cs +++ b/src/MfGames.Nitride.Temporal/Validators/FilterOutFutureInstantValidator.cs @@ -7,7 +7,7 @@ public class FilterOutFutureInstantValidator { public FilterOutFutureInstantValidator() { - this.RuleFor(x => x.Timekeeper) + this.RuleFor(x => x.TimeService) .NotNull(); } } diff --git a/tests/MfGames.Nitride.Temporal.Schedules.Tests/IndexedPathRegexScheduleTest.cs b/tests/MfGames.Nitride.Temporal.Schedules.Tests/IndexedPathRegexScheduleTest.cs index 0d86333..4550fe8 100644 --- a/tests/MfGames.Nitride.Temporal.Schedules.Tests/IndexedPathRegexScheduleTest.cs +++ b/tests/MfGames.Nitride.Temporal.Schedules.Tests/IndexedPathRegexScheduleTest.cs @@ -62,7 +62,7 @@ public class IndexedPathRegexScheduleTest : TemporalSchedulesTestBase // Create the operation and run it, but treat it as being set after the // second but before the third item. - Timekeeper time = context.Resolve(); + TimeService time = context.Resolve(); ApplySchedules op = context.Resolve() .WithGetSchedules(_ => new ISchedule[] { schedules }); var now = Instant.FromUtc(2023, 1, 3, 0, 0); @@ -120,7 +120,7 @@ public class IndexedPathRegexScheduleTest : TemporalSchedulesTestBase // Create the operation and run it, but treat it as being set after the // second but before the third item. - Timekeeper time = context.Resolve(); + TimeService time = context.Resolve(); ApplySchedules op = context.Resolve() .WithGetSchedules(_ => new ISchedule[] { schedules }); var now = Instant.FromUtc(2023, 1, 9, 0, 0); @@ -192,7 +192,7 @@ public class IndexedPathRegexScheduleTest : TemporalSchedulesTestBase // Create the operation and run it, but treat it as being set after the // second but before the third item. - Timekeeper time = context.Resolve(); + TimeService time = context.Resolve(); ApplySchedules op = context.Resolve() .WithGetSchedules(_ => new ISchedule[] { schedules }); var now = Instant.FromUtc(2023, 1, 9, 0, 0); diff --git a/tests/MfGames.Nitride.Temporal.Schedules.Tests/PeriodicPathRegexScheduleTest.cs b/tests/MfGames.Nitride.Temporal.Schedules.Tests/PeriodicPathRegexScheduleTest.cs index 52d4e56..872c9d6 100644 --- a/tests/MfGames.Nitride.Temporal.Schedules.Tests/PeriodicPathRegexScheduleTest.cs +++ b/tests/MfGames.Nitride.Temporal.Schedules.Tests/PeriodicPathRegexScheduleTest.cs @@ -56,7 +56,7 @@ public class PeriodicPathRegexScheduleTest : TemporalSchedulesTestBase // Create the operation and run it, but treat it as being set after the // second but before the third item. - Timekeeper time = context.Resolve(); + TimeService time = context.Resolve(); ApplySchedules op = context.Resolve() .WithGetSchedules(_ => schedules); var now = Instant.FromUtc(2023, 1, 9, 0, 0); @@ -111,7 +111,7 @@ public class PeriodicPathRegexScheduleTest : TemporalSchedulesTestBase // Create the operation and run it, but treat it as being set after the // second but before the third item. - Timekeeper time = context.Resolve(); + TimeService time = context.Resolve(); ApplySchedules op = context.Resolve() .WithGetSchedules(_ => schedules); var now = Instant.FromUtc(2023, 1, 9, 0, 0); @@ -167,7 +167,7 @@ public class PeriodicPathRegexScheduleTest : TemporalSchedulesTestBase // Create the operation and run it, but treat it as being set after the // second but before the third item. - Timekeeper time = context.Resolve(); + TimeService time = context.Resolve(); ApplySchedules op = context.Resolve() .WithGetSchedules(_ => schedules); var now = Instant.FromUtc(2023, 1, 9, 0, 0); @@ -227,7 +227,7 @@ public class PeriodicPathRegexScheduleTest : TemporalSchedulesTestBase // Create the operation and run it, but treat it as being set after the // second but before the third item. - Timekeeper time = context.Resolve(); + TimeService time = context.Resolve(); ApplySchedules op = context.Resolve() .WithGetSchedules(_ => schedules); var now = Instant.FromUtc(2023, 1, 9, 0, 0); diff --git a/tests/MfGames.Nitride.Temporal.Tests/CreateDateIndexesTests.cs b/tests/MfGames.Nitride.Temporal.Tests/CreateDateIndexesTests.cs index 333a03a..dfbc91d 100644 --- a/tests/MfGames.Nitride.Temporal.Tests/CreateDateIndexesTests.cs +++ b/tests/MfGames.Nitride.Temporal.Tests/CreateDateIndexesTests.cs @@ -21,7 +21,7 @@ public class CreateDateIndexesTests : TemporalTestBase public void MonthOnlyIndexes() { using TemporalTestContext context = this.CreateContext(); - Timekeeper timekeeper = context.Resolve(); + TimeService timeService = context.Resolve(); CreateDateIndexes op = context.Resolve() .WithFormats("yyyy-MM") @@ -30,11 +30,11 @@ public class CreateDateIndexesTests : TemporalTestBase List input = new() { new Entity().Add("page1") - .Add(timekeeper.CreateInstant(2021, 1, 2)), + .Add(timeService.CreateInstant(2021, 1, 2)), new Entity().Add("page2") - .Add(timekeeper.CreateInstant(2021, 2, 2)), + .Add(timeService.CreateInstant(2021, 2, 2)), new Entity().Add("page3") - .Add(timekeeper.CreateInstant(2022, 1, 2)), + .Add(timeService.CreateInstant(2022, 1, 2)), }; List?, List?>> actual = @@ -66,7 +66,7 @@ public class CreateDateIndexesTests : TemporalTestBase public void YearMonthDayIndexes() { using TemporalTestContext context = this.CreateContext(); - Timekeeper timekeeper = context.Resolve(); + TimeService timeService = context.Resolve(); CreateDateIndexes op = context.Resolve() .WithFormats("yyyy/MM/dd", "yyyy/MM", "yyyy") @@ -75,11 +75,11 @@ public class CreateDateIndexesTests : TemporalTestBase List input = new() { new Entity().Add("page1") - .Add(timekeeper.CreateInstant(2021, 1, 2)), + .Add(timeService.CreateInstant(2021, 1, 2)), new Entity().Add("page2") - .Add(timekeeper.CreateInstant(2021, 2, 2)), + .Add(timeService.CreateInstant(2021, 2, 2)), new Entity().Add("page3") - .Add(timekeeper.CreateInstant(2022, 1, 2)), + .Add(timeService.CreateInstant(2022, 1, 2)), }; List?, List?>> actual = @@ -131,7 +131,7 @@ public class CreateDateIndexesTests : TemporalTestBase public void YearMonthDayIndexesThreshold1() { using TemporalTestContext context = this.CreateContext(); - Timekeeper timekeeper = context.Resolve(); + TimeService timeService = context.Resolve(); CreateDateIndexes op = context.Resolve() .WithFormats("yyyy/MM/dd", "yyyy/MM", "yyyy") @@ -141,11 +141,11 @@ public class CreateDateIndexesTests : TemporalTestBase List input = new() { new Entity().Add("page1") - .Add(timekeeper.CreateInstant(2021, 1, 2)), + .Add(timeService.CreateInstant(2021, 1, 2)), new Entity().Add("page2") - .Add(timekeeper.CreateInstant(2021, 2, 2)), + .Add(timeService.CreateInstant(2021, 2, 2)), new Entity().Add("page3") - .Add(timekeeper.CreateInstant(2022, 1, 2)), + .Add(timeService.CreateInstant(2022, 1, 2)), }; List?, List?>> actual = @@ -197,7 +197,7 @@ public class CreateDateIndexesTests : TemporalTestBase public void YearMonthIndexes() { using TemporalTestContext context = this.CreateContext(); - Timekeeper timekeeper = context.Resolve(); + TimeService timeService = context.Resolve(); CreateDateIndexes op = context.Resolve() .WithFormats("yyyy-MM", "yyyy") @@ -206,11 +206,11 @@ public class CreateDateIndexesTests : TemporalTestBase List input = new() { new Entity().Add("page1") - .Add(timekeeper.CreateInstant(2021, 1, 2)), + .Add(timeService.CreateInstant(2021, 1, 2)), new Entity().Add("page2") - .Add(timekeeper.CreateInstant(2021, 2, 2)), + .Add(timeService.CreateInstant(2021, 2, 2)), new Entity().Add("page3") - .Add(timekeeper.CreateInstant(2022, 1, 2)), + .Add(timeService.CreateInstant(2022, 1, 2)), }; List?, List?>> actual = @@ -250,7 +250,7 @@ public class CreateDateIndexesTests : TemporalTestBase public void YearOnlyIndexes() { using TemporalTestContext context = this.CreateContext(); - Timekeeper timekeeper = context.Resolve(); + TimeService timeService = context.Resolve(); CreateDateIndexes op = context.Resolve() .WithFormats("yyyy") @@ -259,11 +259,11 @@ public class CreateDateIndexesTests : TemporalTestBase List input = new() { new Entity().Add("page1") - .Add(timekeeper.CreateInstant(2021, 1, 2)), + .Add(timeService.CreateInstant(2021, 1, 2)), new Entity().Add("page2") - .Add(timekeeper.CreateInstant(2021, 2, 2)), + .Add(timeService.CreateInstant(2021, 2, 2)), new Entity().Add("page3") - .Add(timekeeper.CreateInstant(2022, 1, 2)), + .Add(timeService.CreateInstant(2022, 1, 2)), }; List?, List?>> actual = diff --git a/tests/MfGames.Nitride.Temporal.Tests/FilterOutFutureInstantTests.cs b/tests/MfGames.Nitride.Temporal.Tests/FilterOutFutureInstantTests.cs index b2ea424..47af053 100644 --- a/tests/MfGames.Nitride.Temporal.Tests/FilterOutFutureInstantTests.cs +++ b/tests/MfGames.Nitride.Temporal.Tests/FilterOutFutureInstantTests.cs @@ -22,10 +22,10 @@ public class FilterOutFutureInstantTests : TemporalTestBase { // Create the context and set the timestamp to a constant value. using TemporalTestContext context = this.CreateContext(); - Timekeeper timekeeper = context.Resolve(); + TimeService timeService = context.Resolve(); var now = Instant.FromUtc(2000, 6, 1, 0, 0); - timekeeper.Clock = new FakeClock(now); + timeService.Clock = new FakeClock(now); // Create the entities. List input = new() @@ -52,10 +52,10 @@ public class FilterOutFutureInstantTests : TemporalTestBase { // Create the context and set the timestamp to a constant value. using TemporalTestContext context = this.CreateContext(); - Timekeeper timekeeper = context.Resolve(); + TimeService timeService = context.Resolve(); var now = Instant.FromUtc(2000, 6, 1, 0, 0); - timekeeper.Clock = new FakeClock(now); + timeService.Clock = new FakeClock(now); // Create the entities. List input = new()