refactor(temporal)!: renamed Timekeeper to TimeService
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/tag/woodpecker Pipeline was successful

This commit is contained in:
D. Moonfire 2023-01-21 01:52:52 -06:00
parent 82e1bc3c28
commit 07eb12414a
28 changed files with 108 additions and 113 deletions

View file

@ -28,13 +28,13 @@ namespace MfGames.Nitride.Calendar;
[WithProperties] [WithProperties]
public partial class CreateCalender : OperationBase public partial class CreateCalender : OperationBase
{ {
private readonly Timekeeper clock; private readonly TimeService clock;
private readonly IValidator<CreateCalender> validator; private readonly IValidator<CreateCalender> validator;
public CreateCalender( public CreateCalender(
IValidator<CreateCalender> validator, IValidator<CreateCalender> validator,
Timekeeper clock) TimeService clock)
{ {
this.validator = validator; this.validator = validator;
this.clock = clock; this.clock = clock;

View file

@ -20,9 +20,9 @@ public partial class ApplySchedules : OperationBase
public ApplySchedules( public ApplySchedules(
IValidator<ApplySchedules> validator, IValidator<ApplySchedules> validator,
Timekeeper timekeeper) TimeService timeService)
{ {
this.Timekeeper = timekeeper; this.TimeService = timeService;
this.validator = validator; this.validator = validator;
} }
@ -35,9 +35,9 @@ public partial class ApplySchedules : OperationBase
public Func<Entity, IList<ISchedule>?>? GetSchedules { get; set; } public Func<Entity, IList<ISchedule>?>? GetSchedules { get; set; }
/// <summary> /// <summary>
/// Gets or sets the timekeeper associated with this operation. /// Gets or sets the time service associated with this operation.
/// </summary> /// </summary>
public Timekeeper Timekeeper { get; set; } public TimeService TimeService { get; set; }
/// <inheritdoc /> /// <inheritdoc />
public override IEnumerable<Entity> Run( public override IEnumerable<Entity> Run(
@ -79,7 +79,7 @@ public partial class ApplySchedules : OperationBase
continue; continue;
} }
entity = schedule.Apply(entity, this.Timekeeper); entity = schedule.Apply(entity, this.TimeService);
} }
return entity; return entity;

View file

@ -12,14 +12,14 @@ public interface ISchedule
/// Applies the schedule changes to the entity and returns the results. /// Applies the schedule changes to the entity and returns the results.
/// </summary> /// </summary>
/// <param name="entity">The entity to update.</param> /// <param name="entity">The entity to update.</param>
/// <param name="timekeeper">The timekeeper for apply.</param> /// <param name="timeService">The service to use for time.</param>
/// <returns> /// <returns>
/// The modified entity, if the changes can be applied, otherwise the same /// The modified entity, if the changes can be applied, otherwise the same
/// entity. /// entity.
/// </returns> /// </returns>
Entity Apply( Entity Apply(
Entity entity, Entity entity,
Timekeeper timekeeper); TimeService timeService);
/// <summary> /// <summary>
/// Determines if a schedule applies to a given entity. /// Determines if a schedule applies to a given entity.

View file

@ -34,7 +34,7 @@ public partial class IndexedPathRegexSchedule<TSchedule> : PathRegexScheduleBase
protected override Entity Apply( protected override Entity Apply(
Entity entity, Entity entity,
int number, int number,
Timekeeper timekeeper) TimeService timeService)
{ {
// Figure out the entry in the index. // Figure out the entry in the index.
var applicableKeys = this.Indexes.Keys var applicableKeys = this.Indexes.Keys
@ -52,6 +52,6 @@ public partial class IndexedPathRegexSchedule<TSchedule> : PathRegexScheduleBase
// Pass everything into the schedule to perform the applying. // Pass everything into the schedule to perform the applying.
int startOffset = number - startIndex; int startOffset = number - startIndex;
return schedule.Apply(entity, startOffset, timekeeper); return schedule.Apply(entity, startOffset, timeService);
} }
} }

View file

@ -42,7 +42,7 @@ public partial class IndexedSchedule
public virtual Entity Apply( public virtual Entity Apply(
Entity entity, Entity entity,
int number, int number,
Timekeeper timekeeper) TimeService timeService)
{ {
// If we have a "never", then we skip it. // If we have a "never", then we skip it.
TimeSpan? period = this.SchedulePeriodTimeSpan; TimeSpan? period = this.SchedulePeriodTimeSpan;
@ -55,10 +55,10 @@ public partial class IndexedSchedule
// Figure out the time from the start. // Figure out the time from the start.
DateTime when = start.Value + period.Value * number; 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. // 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 return instant > now
? entity ? entity

View file

@ -47,7 +47,7 @@ public abstract partial class PathRegexScheduleBase : ISchedule
/// <inheritdoc /> /// <inheritdoc />
public virtual Entity Apply( public virtual Entity Apply(
Entity entity, Entity entity,
Timekeeper timekeeper) TimeService timeService)
{ {
// Get the path and match it. // Get the path and match it.
string path = this.GetPath(entity); string path = this.GetPath(entity);
@ -83,7 +83,7 @@ public abstract partial class PathRegexScheduleBase : ISchedule
number += this.CaptureOffset; number += this.CaptureOffset;
// Pass it onto the extending class. // Pass it onto the extending class.
return this.Apply(entity, number, timekeeper); return this.Apply(entity, number, timeService);
} }
/// <inheritdoc /> /// <inheritdoc />
@ -107,7 +107,7 @@ public abstract partial class PathRegexScheduleBase : ISchedule
protected abstract Entity Apply( protected abstract Entity Apply(
Entity entity, Entity entity,
int number, int number,
Timekeeper timekeeper); TimeService timeService);
private Regex? GetRegex() private Regex? GetRegex()
{ {

View file

@ -49,7 +49,7 @@ public partial class PeriodicPathRegexSchedule : PathRegexScheduleBase
protected override Entity Apply( protected override Entity Apply(
Entity entity, Entity entity,
int number, int number,
Timekeeper timekeeper) TimeService timeService)
{ {
// If we have a "never", then we skip it. // If we have a "never", then we skip it.
TimeSpan? period = this.SchedulePeriodTimeSpan; TimeSpan? period = this.SchedulePeriodTimeSpan;
@ -62,10 +62,10 @@ public partial class PeriodicPathRegexSchedule : PathRegexScheduleBase
// Figure out the time from the start. // Figure out the time from the start.
DateTime when = start.Value + period.Value * number; 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. // 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 return instant > now
? entity ? entity

View file

@ -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 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` `MfGames.Nitride.Temporal.SetFromComponent` or `MfGames.Nitride.Temporal.SetFromPath`
would be more than sufficient. This is for dynamically changing entities based on would be more than sufficient. This is for dynamically changing entities based on
the date based on `Timekeeper`. the date based on `TimeService`.
## Configuring ## Configuring
@ -53,7 +53,7 @@ The following properties are available (along with their corresponding `With*` m
- `IList<ISchedule> Schedules` - `IList<ISchedule> Schedules`
- Contains the list of schedules to apply against entities. - Contains the list of schedules to apply against entities.
- Defaults to an empty list. - Defaults to an empty list.
- `Timekeeper Timekeeper` - `TimeService TimeService`
- Used to determine when the site is being generated. - Used to determine when the site is being generated.
- Defaults to the one provided by `MfGames.Nitride.Temporal`. - Defaults to the one provided by `MfGames.Nitride.Temporal`.

View file

@ -21,15 +21,15 @@ public partial class SimplePathSchedule : ISchedule
/// <inheritdoc /> /// <inheritdoc />
public virtual Entity Apply( public virtual Entity Apply(
Entity entity, Entity entity,
Timekeeper timekeeper) TimeService timeService)
{ {
DateTime start = this.ScheduleStart DateTime start = this.ScheduleStart
?? throw new NullReferenceException( ?? throw new NullReferenceException(
"Cannot use a schedule without a start date."); "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. // 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 return instant > now
? entity ? entity

View file

@ -9,7 +9,7 @@ public class ApplySchedulesValidator : AbstractValidator<ApplySchedules>
this.RuleFor(x => x.GetSchedules) this.RuleFor(x => x.GetSchedules)
.NotNull(); .NotNull();
this.RuleFor(x => x.Timekeeper) this.RuleFor(x => x.TimeService)
.NotNull(); .NotNull();
} }
} }

View file

@ -20,14 +20,14 @@ public class DatePipelineCommandOption : IPipelineCommandOption
{ {
private readonly ILogger logger; private readonly ILogger logger;
private readonly Timekeeper timekeeper; private readonly TimeService timeService;
public DatePipelineCommandOption( public DatePipelineCommandOption(
ILogger logger, ILogger logger,
Timekeeper timekeeper) TimeService timeService)
{ {
this.logger = logger.ForContext<Instant>(); this.logger = logger.ForContext<Instant>();
this.timekeeper = timekeeper; this.timeService = timeService;
this.Option = new Option<DateTime>("--date") this.Option = new Option<DateTime>("--date")
{ {
@ -53,15 +53,15 @@ public class DatePipelineCommandOption : IPipelineCommandOption
// date for the entire run. // date for the entire run.
var local = LocalDateTime.FromDateTime(value.Value); var local = LocalDateTime.FromDateTime(value.Value);
ZonedDateTime zoned = ZonedDateTime zoned =
local.InZoneStrictly(this.timekeeper.DateTimeZone); local.InZoneStrictly(this.timeService.DateTimeZone);
var instant = zoned.ToInstant(); var instant = zoned.ToInstant();
this.timekeeper.Clock = new FakeClock(instant); this.timeService.Clock = new FakeClock(instant);
} }
// Report the date we are processing. // Report the date we are processing.
Instant now = this.timekeeper.Clock.GetCurrentInstant(); Instant now = this.timeService.Clock.GetCurrentInstant();
ZonedDateTime dateTime = now.InZone(this.timekeeper.DateTimeZone); ZonedDateTime dateTime = now.InZone(this.timeService.DateTimeZone);
string formatted = dateTime.ToString("G", CultureInfo.InvariantCulture); string formatted = dateTime.ToString("G", CultureInfo.InvariantCulture);
this.logger.Information("Setting date/time to {When:l}", formatted); this.logger.Information("Setting date/time to {When:l}", formatted);

View file

@ -18,13 +18,13 @@ namespace MfGames.Nitride.Temporal.Cli;
/// </summary> /// </summary>
public class ExpiresPipelineCommandOption : IPipelineCommandOption public class ExpiresPipelineCommandOption : IPipelineCommandOption
{ {
private readonly Timekeeper clock; private readonly TimeService clock;
private readonly ILogger logger; private readonly ILogger logger;
public ExpiresPipelineCommandOption( public ExpiresPipelineCommandOption(
ILogger logger, ILogger logger,
Timekeeper clock, TimeService clock,
string? defaultValue = null) string? defaultValue = null)
{ {
this.logger = logger.ForContext<Instant>(); this.logger = logger.ForContext<Instant>();

View file

@ -25,10 +25,10 @@ public partial class CreateDateIndexes : OperationBase, IResolvingOperation
public CreateDateIndexes( public CreateDateIndexes(
IValidator<CreateDateIndexes> validator, IValidator<CreateDateIndexes> validator,
Timekeeper timekeeper) TimeService timeService)
{ {
this.validator = validator; this.validator = validator;
this.Timekeeper = timekeeper; this.TimeService = timeService;
} }
/// <summary> /// <summary>
@ -51,7 +51,7 @@ public partial class CreateDateIndexes : OperationBase, IResolvingOperation
/// </summary> /// </summary>
public int LessThanEqualCollapse { get; set; } public int LessThanEqualCollapse { get; set; }
public Timekeeper Timekeeper { get; } public TimeService TimeService { get; }
/// <inheritdoc /> /// <inheritdoc />
public override IEnumerable<Entity> Run( public override IEnumerable<Entity> Run(
@ -136,7 +136,7 @@ public partial class CreateDateIndexes : OperationBase, IResolvingOperation
Entity? first = pair.Value[0]; Entity? first = pair.Value[0];
string? nextKey = this.Timekeeper string? nextKey = this.TimeService
.ToDateTime(first.Get<Instant>()) .ToDateTime(first.Get<Instant>())
.ToString(this.Formats[i + 1]); .ToString(this.Formats[i + 1]);
@ -166,7 +166,7 @@ public partial class CreateDateIndexes : OperationBase, IResolvingOperation
List<Dictionary<string, List<Entity>>> grouped, List<Dictionary<string, List<Entity>>> grouped,
Entity entity) Entity entity)
{ {
var dateTime = this.Timekeeper.ToDateTime(instant); var dateTime = this.TimeService.ToDateTime(instant);
for (int i = 0; i < this.Formats.Count; i++) for (int i = 0; i < this.Formats.Count; i++)
{ {

View file

@ -20,13 +20,13 @@ public partial class FilterOutExpiredInstant : OperationBase
public FilterOutExpiredInstant( public FilterOutExpiredInstant(
IValidator<FilterOutExpiredInstant> validator, IValidator<FilterOutExpiredInstant> validator,
Timekeeper clock) TimeService clock)
{ {
this.validator = validator; this.validator = validator;
this.Timekeeper = clock; this.TimeService = clock;
} }
public Timekeeper Timekeeper { get; set; } public TimeService TimeService { get; set; }
/// <inheritdoc /> /// <inheritdoc />
public override IEnumerable<Entity> Run( public override IEnumerable<Entity> Run(
@ -35,7 +35,7 @@ public partial class FilterOutExpiredInstant : OperationBase
{ {
this.validator.ValidateAndThrow(this); this.validator.ValidateAndThrow(this);
if (!this.Timekeeper.Expiration.HasValue) if (!this.TimeService.Expiration.HasValue)
{ {
return input; return input;
} }
@ -48,7 +48,7 @@ public partial class FilterOutExpiredInstant : OperationBase
Instant instant, Instant instant,
CanExpire _) CanExpire _)
{ {
Instant expiration = this.Timekeeper.Expiration!.Value; Instant expiration = this.TimeService.Expiration!.Value;
bool isExpired = instant.CompareTo(expiration) < 0; bool isExpired = instant.CompareTo(expiration) < 0;
return isExpired ? null : entity; return isExpired ? null : entity;

View file

@ -15,19 +15,19 @@ namespace MfGames.Nitride.Temporal;
[WithProperties] [WithProperties]
public partial class FilterOutFutureInstant : OperationBase 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; }
/// <inheritdoc /> /// <inheritdoc />
public override IEnumerable<Entity> Run( public override IEnumerable<Entity> Run(
IEnumerable<Entity> input, IEnumerable<Entity> input,
CancellationToken cancellationToken = default) CancellationToken cancellationToken = default)
{ {
Instant now = this.Timekeeper.Clock.GetCurrentInstant(); Instant now = this.TimeService.Clock.GetCurrentInstant();
return input return input
.SelectEntity<Instant>( .SelectEntity<Instant>(

View file

@ -10,18 +10,18 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Autofac" Version="6.4.0"/> <PackageReference Include="Autofac" Version="6.4.0" />
<PackageReference Include="MfGames.Gallium" Version="0.4.0"/> <PackageReference Include="MfGames.Gallium" Version="0.4.0" />
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="6.0.0"/> <PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="6.0.0" />
<PackageReference Include="NodaTime" Version="3.1.2"/> <PackageReference Include="NodaTime" Version="3.1.2" />
<PackageReference Include="NodaTime.Testing" Version="3.1.2"/> <PackageReference Include="NodaTime.Testing" Version="3.1.2" />
<PackageReference Include="Serilog" Version="2.11.0"/> <PackageReference Include="Serilog" Version="2.11.0" />
<PackageReference Include="TimeSpanParserUtil" Version="1.2.0"/> <PackageReference Include="TimeSpanParserUtil" Version="1.2.0" />
<PackageReference Include="Zio" Version="0.15.0"/> <PackageReference Include="Zio" Version="0.15.0" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\MfGames.Nitride\MfGames.Nitride.csproj"/> <ProjectReference Include="..\MfGames.Nitride\MfGames.Nitride.csproj" />
</ItemGroup> </ItemGroup>
<!-- Include the source generator --> <!-- Include the source generator -->

View file

@ -17,11 +17,11 @@ namespace MfGames.Nitride.Temporal;
/// </summary> /// </summary>
public class SetInstantFromComponent<TComponent> : OperationBase public class SetInstantFromComponent<TComponent> : OperationBase
{ {
private readonly Timekeeper clock; private readonly TimeService clock;
private readonly IValidator<SetInstantFromComponent<TComponent>> validator; private readonly IValidator<SetInstantFromComponent<TComponent>> validator;
public SetInstantFromComponent(Timekeeper clock) public SetInstantFromComponent(TimeService clock)
{ {
// TODO: Figure out why Autofac won't let us register IValidator of generic classes. // TODO: Figure out why Autofac won't let us register IValidator of generic classes.
this.validator = new SetInstantFromComponentValidator<TComponent>(); this.validator = new SetInstantFromComponentValidator<TComponent>();
@ -73,6 +73,7 @@ public class SetInstantFromComponent<TComponent> : OperationBase
{ {
case null: case null:
return entity; return entity;
case Instant direct: case Instant direct:
instant = direct; instant = direct;

View file

@ -23,13 +23,13 @@ namespace MfGames.Nitride.Temporal;
[WithProperties] [WithProperties]
public partial class SetInstantFromPath : OperationBase public partial class SetInstantFromPath : OperationBase
{ {
private readonly Timekeeper clock; private readonly TimeService clock;
private readonly IValidator<SetInstantFromPath> validator; private readonly IValidator<SetInstantFromPath> validator;
public SetInstantFromPath( public SetInstantFromPath(
IValidator<SetInstantFromPath> validator, IValidator<SetInstantFromPath> validator,
Timekeeper clock) TimeService clock)
{ {
this.validator = validator; this.validator = validator;
this.clock = clock; this.clock = clock;
@ -67,15 +67,9 @@ public partial class SetInstantFromPath : OperationBase
// Create an Instant from this. // Create an Instant from this.
Instant instant = this.clock.CreateInstant( Instant instant = this.clock.CreateInstant(
Convert.ToInt32( Convert.ToInt32(match.Groups["year"].Value),
match.Groups["year"] Convert.ToInt32(match.Groups["month"].Value),
.Value), Convert.ToInt32(match.Groups["day"].Value));
Convert.ToInt32(
match.Groups["month"]
.Value),
Convert.ToInt32(
match.Groups["day"]
.Value));
return entity.Set(instant); return entity.Set(instant);
} }

View file

@ -45,8 +45,8 @@ public static class NitrideTemporalBuilderExtensions
context => context =>
{ {
ILogger logger = context.Resolve<ILogger>(); ILogger logger = context.Resolve<ILogger>();
Timekeeper TimeService
clock = context.Resolve<Timekeeper>(); clock = context.Resolve<TimeService>();
return new ExpiresPipelineCommandOption( return new ExpiresPipelineCommandOption(
logger, logger,
@ -65,12 +65,12 @@ public static class NitrideTemporalBuilderExtensions
scope) => scope) =>
{ {
ILogger logger = scope.Resolve<ILogger>(); ILogger logger = scope.Resolve<ILogger>();
Timekeeper timekeeper = scope.Resolve<Timekeeper>(); TimeService timeService = scope.Resolve<TimeService>();
timekeeper.DateTimeZone = config.DateTimeZone; timeService.DateTimeZone = config.DateTimeZone;
logger.Verbose( logger.Verbose(
"Setting time zone to {Zone:l}", "Setting time zone to {Zone:l}",
timekeeper.DateTimeZone); timeService.DateTimeZone);
}); });
} }

View file

@ -10,7 +10,7 @@ public class NitrideTemporalModule : Module
builder.RegisterOperators(this); builder.RegisterOperators(this);
builder.RegisterValidators(this); builder.RegisterValidators(this);
builder.RegisterType<Timekeeper>() builder.RegisterType<TimeService>()
.AsSelf() .AsSelf()
.SingleInstance(); .SingleInstance();

View file

@ -10,9 +10,9 @@ namespace MfGames.Nitride.Temporal;
/// the desire time zone along with various methods for processing parsed /// the desire time zone along with various methods for processing parsed
/// DateTime objects into NodaTime.Instant. /// DateTime objects into NodaTime.Instant.
/// </summary> /// </summary>
public class Timekeeper public class TimeService
{ {
public Timekeeper() public TimeService()
{ {
// We use FakeClock because we don't want time to advance in the // 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 // middle of running, just in case we are just a few seconds before

View file

@ -6,7 +6,7 @@ public class CreateDateIndexesValidator : AbstractValidator<CreateDateIndexes>
{ {
public CreateDateIndexesValidator() public CreateDateIndexesValidator()
{ {
this.RuleFor(a => a.Timekeeper) this.RuleFor(a => a.TimeService)
.NotNull(); .NotNull();
this.RuleFor(a => a.CreateIndex) this.RuleFor(a => a.CreateIndex)

View file

@ -7,7 +7,7 @@ public class FilterOutExpiredInstantValidator
{ {
public FilterOutExpiredInstantValidator() public FilterOutExpiredInstantValidator()
{ {
this.RuleFor(x => x.Timekeeper) this.RuleFor(x => x.TimeService)
.NotNull(); .NotNull();
} }
} }

View file

@ -7,7 +7,7 @@ public class FilterOutFutureInstantValidator
{ {
public FilterOutFutureInstantValidator() public FilterOutFutureInstantValidator()
{ {
this.RuleFor(x => x.Timekeeper) this.RuleFor(x => x.TimeService)
.NotNull(); .NotNull();
} }
} }

View file

@ -62,7 +62,7 @@ public class IndexedPathRegexScheduleTest : TemporalSchedulesTestBase
// Create the operation and run it, but treat it as being set after the // Create the operation and run it, but treat it as being set after the
// second but before the third item. // second but before the third item.
Timekeeper time = context.Resolve<Timekeeper>(); TimeService time = context.Resolve<TimeService>();
ApplySchedules op = context.Resolve<ApplySchedules>() ApplySchedules op = context.Resolve<ApplySchedules>()
.WithGetSchedules(_ => new ISchedule[] { schedules }); .WithGetSchedules(_ => new ISchedule[] { schedules });
var now = Instant.FromUtc(2023, 1, 3, 0, 0); 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 // Create the operation and run it, but treat it as being set after the
// second but before the third item. // second but before the third item.
Timekeeper time = context.Resolve<Timekeeper>(); TimeService time = context.Resolve<TimeService>();
ApplySchedules op = context.Resolve<ApplySchedules>() ApplySchedules op = context.Resolve<ApplySchedules>()
.WithGetSchedules(_ => new ISchedule[] { schedules }); .WithGetSchedules(_ => new ISchedule[] { schedules });
var now = Instant.FromUtc(2023, 1, 9, 0, 0); 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 // Create the operation and run it, but treat it as being set after the
// second but before the third item. // second but before the third item.
Timekeeper time = context.Resolve<Timekeeper>(); TimeService time = context.Resolve<TimeService>();
ApplySchedules op = context.Resolve<ApplySchedules>() ApplySchedules op = context.Resolve<ApplySchedules>()
.WithGetSchedules(_ => new ISchedule[] { schedules }); .WithGetSchedules(_ => new ISchedule[] { schedules });
var now = Instant.FromUtc(2023, 1, 9, 0, 0); var now = Instant.FromUtc(2023, 1, 9, 0, 0);

View file

@ -56,7 +56,7 @@ public class PeriodicPathRegexScheduleTest : TemporalSchedulesTestBase
// Create the operation and run it, but treat it as being set after the // Create the operation and run it, but treat it as being set after the
// second but before the third item. // second but before the third item.
Timekeeper time = context.Resolve<Timekeeper>(); TimeService time = context.Resolve<TimeService>();
ApplySchedules op = context.Resolve<ApplySchedules>() ApplySchedules op = context.Resolve<ApplySchedules>()
.WithGetSchedules(_ => schedules); .WithGetSchedules(_ => schedules);
var now = Instant.FromUtc(2023, 1, 9, 0, 0); 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 // Create the operation and run it, but treat it as being set after the
// second but before the third item. // second but before the third item.
Timekeeper time = context.Resolve<Timekeeper>(); TimeService time = context.Resolve<TimeService>();
ApplySchedules op = context.Resolve<ApplySchedules>() ApplySchedules op = context.Resolve<ApplySchedules>()
.WithGetSchedules(_ => schedules); .WithGetSchedules(_ => schedules);
var now = Instant.FromUtc(2023, 1, 9, 0, 0); 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 // Create the operation and run it, but treat it as being set after the
// second but before the third item. // second but before the third item.
Timekeeper time = context.Resolve<Timekeeper>(); TimeService time = context.Resolve<TimeService>();
ApplySchedules op = context.Resolve<ApplySchedules>() ApplySchedules op = context.Resolve<ApplySchedules>()
.WithGetSchedules(_ => schedules); .WithGetSchedules(_ => schedules);
var now = Instant.FromUtc(2023, 1, 9, 0, 0); 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 // Create the operation and run it, but treat it as being set after the
// second but before the third item. // second but before the third item.
Timekeeper time = context.Resolve<Timekeeper>(); TimeService time = context.Resolve<TimeService>();
ApplySchedules op = context.Resolve<ApplySchedules>() ApplySchedules op = context.Resolve<ApplySchedules>()
.WithGetSchedules(_ => schedules); .WithGetSchedules(_ => schedules);
var now = Instant.FromUtc(2023, 1, 9, 0, 0); var now = Instant.FromUtc(2023, 1, 9, 0, 0);

View file

@ -21,7 +21,7 @@ public class CreateDateIndexesTests : TemporalTestBase
public void MonthOnlyIndexes() public void MonthOnlyIndexes()
{ {
using TemporalTestContext context = this.CreateContext(); using TemporalTestContext context = this.CreateContext();
Timekeeper timekeeper = context.Resolve<Timekeeper>(); TimeService timeService = context.Resolve<TimeService>();
CreateDateIndexes op = context.Resolve<CreateDateIndexes>() CreateDateIndexes op = context.Resolve<CreateDateIndexes>()
.WithFormats("yyyy-MM") .WithFormats("yyyy-MM")
@ -30,11 +30,11 @@ public class CreateDateIndexesTests : TemporalTestBase
List<Entity> input = new() List<Entity> input = new()
{ {
new Entity().Add("page1") new Entity().Add("page1")
.Add(timekeeper.CreateInstant(2021, 1, 2)), .Add(timeService.CreateInstant(2021, 1, 2)),
new Entity().Add("page2") new Entity().Add("page2")
.Add(timekeeper.CreateInstant(2021, 2, 2)), .Add(timeService.CreateInstant(2021, 2, 2)),
new Entity().Add("page3") new Entity().Add("page3")
.Add(timekeeper.CreateInstant(2022, 1, 2)), .Add(timeService.CreateInstant(2022, 1, 2)),
}; };
List<Tuple<string, List<string>?, List<string>?>> actual = List<Tuple<string, List<string>?, List<string>?>> actual =
@ -66,7 +66,7 @@ public class CreateDateIndexesTests : TemporalTestBase
public void YearMonthDayIndexes() public void YearMonthDayIndexes()
{ {
using TemporalTestContext context = this.CreateContext(); using TemporalTestContext context = this.CreateContext();
Timekeeper timekeeper = context.Resolve<Timekeeper>(); TimeService timeService = context.Resolve<TimeService>();
CreateDateIndexes op = context.Resolve<CreateDateIndexes>() CreateDateIndexes op = context.Resolve<CreateDateIndexes>()
.WithFormats("yyyy/MM/dd", "yyyy/MM", "yyyy") .WithFormats("yyyy/MM/dd", "yyyy/MM", "yyyy")
@ -75,11 +75,11 @@ public class CreateDateIndexesTests : TemporalTestBase
List<Entity> input = new() List<Entity> input = new()
{ {
new Entity().Add("page1") new Entity().Add("page1")
.Add(timekeeper.CreateInstant(2021, 1, 2)), .Add(timeService.CreateInstant(2021, 1, 2)),
new Entity().Add("page2") new Entity().Add("page2")
.Add(timekeeper.CreateInstant(2021, 2, 2)), .Add(timeService.CreateInstant(2021, 2, 2)),
new Entity().Add("page3") new Entity().Add("page3")
.Add(timekeeper.CreateInstant(2022, 1, 2)), .Add(timeService.CreateInstant(2022, 1, 2)),
}; };
List<Tuple<string, List<string>?, List<string>?>> actual = List<Tuple<string, List<string>?, List<string>?>> actual =
@ -131,7 +131,7 @@ public class CreateDateIndexesTests : TemporalTestBase
public void YearMonthDayIndexesThreshold1() public void YearMonthDayIndexesThreshold1()
{ {
using TemporalTestContext context = this.CreateContext(); using TemporalTestContext context = this.CreateContext();
Timekeeper timekeeper = context.Resolve<Timekeeper>(); TimeService timeService = context.Resolve<TimeService>();
CreateDateIndexes op = context.Resolve<CreateDateIndexes>() CreateDateIndexes op = context.Resolve<CreateDateIndexes>()
.WithFormats("yyyy/MM/dd", "yyyy/MM", "yyyy") .WithFormats("yyyy/MM/dd", "yyyy/MM", "yyyy")
@ -141,11 +141,11 @@ public class CreateDateIndexesTests : TemporalTestBase
List<Entity> input = new() List<Entity> input = new()
{ {
new Entity().Add("page1") new Entity().Add("page1")
.Add(timekeeper.CreateInstant(2021, 1, 2)), .Add(timeService.CreateInstant(2021, 1, 2)),
new Entity().Add("page2") new Entity().Add("page2")
.Add(timekeeper.CreateInstant(2021, 2, 2)), .Add(timeService.CreateInstant(2021, 2, 2)),
new Entity().Add("page3") new Entity().Add("page3")
.Add(timekeeper.CreateInstant(2022, 1, 2)), .Add(timeService.CreateInstant(2022, 1, 2)),
}; };
List<Tuple<string, List<string>?, List<string>?>> actual = List<Tuple<string, List<string>?, List<string>?>> actual =
@ -197,7 +197,7 @@ public class CreateDateIndexesTests : TemporalTestBase
public void YearMonthIndexes() public void YearMonthIndexes()
{ {
using TemporalTestContext context = this.CreateContext(); using TemporalTestContext context = this.CreateContext();
Timekeeper timekeeper = context.Resolve<Timekeeper>(); TimeService timeService = context.Resolve<TimeService>();
CreateDateIndexes op = context.Resolve<CreateDateIndexes>() CreateDateIndexes op = context.Resolve<CreateDateIndexes>()
.WithFormats("yyyy-MM", "yyyy") .WithFormats("yyyy-MM", "yyyy")
@ -206,11 +206,11 @@ public class CreateDateIndexesTests : TemporalTestBase
List<Entity> input = new() List<Entity> input = new()
{ {
new Entity().Add("page1") new Entity().Add("page1")
.Add(timekeeper.CreateInstant(2021, 1, 2)), .Add(timeService.CreateInstant(2021, 1, 2)),
new Entity().Add("page2") new Entity().Add("page2")
.Add(timekeeper.CreateInstant(2021, 2, 2)), .Add(timeService.CreateInstant(2021, 2, 2)),
new Entity().Add("page3") new Entity().Add("page3")
.Add(timekeeper.CreateInstant(2022, 1, 2)), .Add(timeService.CreateInstant(2022, 1, 2)),
}; };
List<Tuple<string, List<string>?, List<string>?>> actual = List<Tuple<string, List<string>?, List<string>?>> actual =
@ -250,7 +250,7 @@ public class CreateDateIndexesTests : TemporalTestBase
public void YearOnlyIndexes() public void YearOnlyIndexes()
{ {
using TemporalTestContext context = this.CreateContext(); using TemporalTestContext context = this.CreateContext();
Timekeeper timekeeper = context.Resolve<Timekeeper>(); TimeService timeService = context.Resolve<TimeService>();
CreateDateIndexes op = context.Resolve<CreateDateIndexes>() CreateDateIndexes op = context.Resolve<CreateDateIndexes>()
.WithFormats("yyyy") .WithFormats("yyyy")
@ -259,11 +259,11 @@ public class CreateDateIndexesTests : TemporalTestBase
List<Entity> input = new() List<Entity> input = new()
{ {
new Entity().Add("page1") new Entity().Add("page1")
.Add(timekeeper.CreateInstant(2021, 1, 2)), .Add(timeService.CreateInstant(2021, 1, 2)),
new Entity().Add("page2") new Entity().Add("page2")
.Add(timekeeper.CreateInstant(2021, 2, 2)), .Add(timeService.CreateInstant(2021, 2, 2)),
new Entity().Add("page3") new Entity().Add("page3")
.Add(timekeeper.CreateInstant(2022, 1, 2)), .Add(timeService.CreateInstant(2022, 1, 2)),
}; };
List<Tuple<string, List<string>?, List<string>?>> actual = List<Tuple<string, List<string>?, List<string>?>> actual =

View file

@ -22,10 +22,10 @@ public class FilterOutFutureInstantTests : TemporalTestBase
{ {
// Create the context and set the timestamp to a constant value. // Create the context and set the timestamp to a constant value.
using TemporalTestContext context = this.CreateContext(); using TemporalTestContext context = this.CreateContext();
Timekeeper timekeeper = context.Resolve<Timekeeper>(); TimeService timeService = context.Resolve<TimeService>();
var now = Instant.FromUtc(2000, 6, 1, 0, 0); var now = Instant.FromUtc(2000, 6, 1, 0, 0);
timekeeper.Clock = new FakeClock(now); timeService.Clock = new FakeClock(now);
// Create the entities. // Create the entities.
List<Entity> input = new() List<Entity> input = new()
@ -52,10 +52,10 @@ public class FilterOutFutureInstantTests : TemporalTestBase
{ {
// Create the context and set the timestamp to a constant value. // Create the context and set the timestamp to a constant value.
using TemporalTestContext context = this.CreateContext(); using TemporalTestContext context = this.CreateContext();
Timekeeper timekeeper = context.Resolve<Timekeeper>(); TimeService timeService = context.Resolve<TimeService>();
var now = Instant.FromUtc(2000, 6, 1, 0, 0); var now = Instant.FromUtc(2000, 6, 1, 0, 0);
timekeeper.Clock = new FakeClock(now); timeService.Clock = new FakeClock(now);
// Create the entities. // Create the entities.
List<Entity> input = new() List<Entity> input = new()