Skip to content

Commit 1d698fc

Browse files
authored
Merge pull request #2 from Shuttle/v21
V21
2 parents 005dbc1 + d5f5903 commit 1d698fc

28 files changed

Lines changed: 152 additions & 338 deletions

README.md

Lines changed: 32 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,64 @@
11
# Shuttle.Core.System
22

3+
OS and system level abstractions that provide a way to decouple your logic from static system calls, making your code more testable.
4+
5+
## Why?
6+
7+
When your code calls `DateTimeOffset.UtcNow`, `Environment.UserInteractive`, or `Process.GetCurrentProcess()`, it is difficult to unit test that code because these are static calls to the operating system. By using these abstractions, you can mock the system-level behavior in your tests.
8+
9+
## Installation
10+
11+
```bash
12+
dotnet add package Shuttle.Core.System
313
```
4-
PM> Install-Package Shuttle.Core.System
14+
15+
## Usage
16+
17+
Register the services with your dependency injection container:
18+
19+
```csharp
20+
services.AddSingleton<ISystemClock, SystemClock>();
21+
services.AddSingleton<IEnvironmentService, EnvironmentService>();
22+
services.AddSingleton<IProcessService, ProcessService>();
523
```
624

7-
OS and system level abstractions.
25+
All types are in the `Shuttle.Core.System` namespace.
826

9-
## ISystemClock
27+
## `ISystemClock`
1028

1129
The default implementation is `SystemClock`.
1230

13-
``` c#
31+
```csharp
1432
DateTimeOffset UtcNow { get; }
1533
```
1634

17-
Return the `DataTimeOffset` as the current UTC data/time.
35+
Returns the `DateTimeOffset` representing the current UTC date/time.
1836

19-
## IEnvironmentService
37+
## `IEnvironmentService`
2038

2139
The default implementation is `EnvironmentService`.
2240

23-
``` c#
41+
```csharp
2442
bool UserInteractive { get; }
2543
```
2644

27-
Return `true` if running as a console application; else `false`.
45+
Returns `true` if running as a console application; otherwise `false`.
2846

29-
## IProcessService
47+
## `IProcessService`
3048

3149
The default implementation is `ProcessService`.
3250

33-
``` c#
51+
```csharp
3452
IProcess GetCurrentProcess();
3553
```
3654

37-
Returns the `IProcess` abstraction for the current process.
55+
Returns an `IProcess` abstraction for the current system process.
3856

39-
## IProcess
57+
## `IProcess`
4058

41-
Represents a system process and the default implementation is `SystemProcess`.
59+
Represents a system process. The default implementation is `SystemProcess`.
4260

43-
``` c#
61+
```csharp
4462
void Kill();
4563
```
4664

Shuttle.Core.System.sln

Lines changed: 0 additions & 31 deletions
This file was deleted.

Shuttle.Core.System/.package/AssemblyInfo.cs.template

Lines changed: 0 additions & 11 deletions
This file was deleted.
-18 KB
Binary file not shown.

Shuttle.Core.System/.package/Shuttle.NuGetPackager.targets

Lines changed: 0 additions & 12 deletions
This file was deleted.

Shuttle.Core.System/.package/package.msbuild

Lines changed: 0 additions & 104 deletions
This file was deleted.

Shuttle.Core.System/.package/package.nuspec

Lines changed: 0 additions & 27 deletions
This file was deleted.

Shuttle.Core.System/.package/package.nuspec.template

Lines changed: 0 additions & 27 deletions
This file was deleted.

Shuttle.Core.System/EnvironmentService.cs

Lines changed: 0 additions & 9 deletions
This file was deleted.

Shuttle.Core.System/IEnvironmentService.cs

Lines changed: 0 additions & 7 deletions
This file was deleted.

0 commit comments

Comments
 (0)