-
Notifications
You must be signed in to change notification settings - Fork 268
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: use contract builder for domain unit tests
- Loading branch information
1 parent
c3d1392
commit 2864e45
Showing
4 changed files
with
75 additions
and
36 deletions.
There are no files selected for viewing
23 changes: 23 additions & 0 deletions
23
....Contracts/Src/Fitnet.Contracts.Core.UnitTests/PrepareContract/PreparedContractBuilder.cs
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 |
---|---|---|
@@ -0,0 +1,23 @@ | ||
namespace EvolutionaryArchitecture.Fitnet.Contracts.Core.UnitTests.PrepareContract; | ||
|
||
public class PreparedContractBuilder(Contract parentBuilder) | ||
{ | ||
private DateTimeOffset _signDay; | ||
private DateTimeOffset _fakeToday; | ||
|
||
public PreparedContractBuilder SignedOn(DateTimeOffset signDay, DateTimeOffset fakeToday) | ||
{ | ||
_signDay = signDay; | ||
_fakeToday = fakeToday; | ||
return this; | ||
} | ||
|
||
private BindingContract Build() | ||
{ | ||
var bindingContract = parentBuilder.Sign(_signDay, _fakeToday); | ||
|
||
return bindingContract; | ||
} | ||
|
||
public static implicit operator BindingContract(PreparedContractBuilder builder) => builder.Build(); | ||
} |
32 changes: 32 additions & 0 deletions
32
...sign/Fitnet.Contracts/Src/Fitnet.Contracts.Core.UnitTests/SignContract/ContractBuilder.cs
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 |
---|---|---|
@@ -0,0 +1,32 @@ | ||
namespace EvolutionaryArchitecture.Fitnet.Contracts.Core.UnitTests.SignContract; | ||
|
||
using PrepareContract; | ||
|
||
public class ContractBuilder | ||
{ | ||
public static ContractBuilder Create() => new(); | ||
|
||
private DateTimeOffset _preparedAt; | ||
|
||
public ContractBuilder PreparedAt(DateTimeOffset preparedAt) | ||
{ | ||
_preparedAt = preparedAt; | ||
return this; | ||
} | ||
|
||
public PreparedContractBuilder Prepared() => new(Build()); | ||
|
||
private Contract Build() | ||
{ | ||
var prepareContractParameters = PrepareContractParameters.GetValid(); | ||
var contract = Contract.Prepare( | ||
Guid.NewGuid(), | ||
prepareContractParameters.MaxAge, | ||
prepareContractParameters.MaxHeight, | ||
_preparedAt); | ||
|
||
return contract; | ||
} | ||
|
||
public static implicit operator Contract(ContractBuilder builder) => builder.Build(); | ||
} |
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