Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 0 additions & 20 deletions src/Microsoft.FeatureManagement/FeatureFilters/ISystemClock.cs

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public TimeWindowFilter(ILoggerFactory loggerFactory = null)
/// <summary>
/// This property allows the time window filter in our test suite to use simulated time.
/// </summary>
internal ISystemClock SystemClock { get; set; }
internal TimeProvider SystemClock { get; set; }

/// <summary>
/// Binds configuration representing filter parameters to <see cref="TimeWindowFilterSettings"/>.
Expand Down Expand Up @@ -74,7 +74,7 @@ public Task<bool> EvaluateAsync(FeatureFilterEvaluationContext context)
// Check if prebound settings available, otherwise bind from parameters.
TimeWindowFilterSettings settings = (TimeWindowFilterSettings)context.Settings ?? (TimeWindowFilterSettings)BindParameters(context.Parameters);

DateTimeOffset now = SystemClock?.UtcNow ?? DateTimeOffset.UtcNow;
DateTimeOffset now = SystemClock?.GetUtcNow() ?? DateTimeOffset.UtcNow;

if (!settings.Start.HasValue && !settings.End.HasValue)
{
Expand Down Expand Up @@ -129,7 +129,7 @@ public Task<bool> EvaluateAsync(FeatureFilterEvaluationContext context)

private DateTimeOffset? ReloadClosestStart(TimeWindowFilterSettings settings)
{
DateTimeOffset now = SystemClock?.UtcNow ?? DateTimeOffset.UtcNow;
DateTimeOffset now = SystemClock?.GetUtcNow() ?? DateTimeOffset.UtcNow;

DateTimeOffset? closestStart = RecurrenceEvaluator.CalculateClosestStart(now, settings);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,11 @@
</PropertyGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
<PackageReference Include="Microsoft.Bcl.AsyncInterfaces" Version="1.1.1" />
<PackageReference Include="Microsoft.Bcl.AsyncInterfaces" Version="8.0.0" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Bcl.TimeProvider" Version="8.0.1" />
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="2.1.23" />
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="2.1.10" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="2.1.1" />
Expand Down
10 changes: 7 additions & 3 deletions tests/Tests.FeatureManagement/OnDemandClock.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
using Microsoft.FeatureManagement.FeatureFilters;
using System;
using System;

namespace Tests.FeatureManagement
{
class OnDemandClock : ISystemClock
class OnDemandClock : TimeProvider
{
public DateTimeOffset UtcNow { get; set; }

public override DateTimeOffset GetUtcNow()
{
return UtcNow;
}
}
}