forked from dotnet/extensions
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix FakeTimeProvider namespace, add readme
- Loading branch information
Showing
7 changed files
with
69 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 47 additions & 1 deletion
48
src/Libraries/Microsoft.Extensions.TimeProvider.Testing/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,47 @@ | ||
README | ||
# Microsoft.Extensions.TimeProvider.Testing | ||
|
||
Provides a `FakeTimeProvider` for testing components that depend on `System.TimeProvider`. | ||
|
||
## Install the package | ||
|
||
From the command-line: | ||
|
||
```dotnetcli | ||
dotnet add package Microsoft.Extensions.TimeProvider.Testing | ||
``` | ||
|
||
Or directly in the C# project file: | ||
|
||
```xml | ||
<ItemGroup> | ||
<PackageReference Include="Microsoft.Extensions.TimeProvider.Testing" Version="[CURRENTVERSION]" /> | ||
</ItemGroup> | ||
``` | ||
|
||
## FakeTimeProvider | ||
|
||
`FakeTimeProvider` can be used to manually adjust time to test time dependent components in a deterministic way. | ||
|
||
`FakeTimeProvider` derives from TimeProvider and adds the following APIs: | ||
|
||
```csharp | ||
public FakeTimeProvider(DateTimeOffset startDateTime) | ||
public DateTimeOffset Start { get; } | ||
public TimeSpan AutoAdvanceAmount | ||
public void SetUtcNow(DateTimeOffset value) | ||
public void Advance(TimeSpan delta) | ||
public void SetLocalTimeZone(TimeZoneInfo localTimeZone) | ||
``` | ||
|
||
For example: | ||
|
||
```csharp | ||
var timeProvider = new FakeTimeProvider(); | ||
var myComponent = new MyComponent(timeProvider); | ||
timeProvider.Advance(TimeSpan.FromSeconds(5)); | ||
myComponent.CheckState(); | ||
``` | ||
|
||
## Feedback & Contributing | ||
|
||
For any feedback or contributions, please visit us in [our GitHub repo](https://github.com/dotnet/extensions). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters