-
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.
Merge branch 'main' into feature/add-github-nuget-feed-as-part-of-sol…
…ution
- Loading branch information
Showing
34 changed files
with
399 additions
and
49 deletions.
There are no files selected for viewing
4 changes: 3 additions & 1 deletion
4
...et.Contracts.Core/IContractsRepository.cs → ...racts.Application/IContractsRepository.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
1 change: 0 additions & 1 deletion
1
...tion/Fitnet.Contracts/Src/Fitnet.Contracts.Application/Sign/SignContractCommandHandler.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
1 change: 1 addition & 0 deletions
1
...ontracts/Src/Fitnet.Contracts.Infrastructure/Database/Repositories/ContractsRepository.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
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
4 changes: 3 additions & 1 deletion
4
...racts.Core/IBindingContractsRepository.cs → ...pplication/IBindingContractsRepository.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
6 changes: 4 additions & 2 deletions
6
...et.Contracts.Core/IContractsRepository.cs → ...racts.Application/IContractsRepository.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 |
---|---|---|
@@ -1,9 +1,11 @@ | ||
namespace EvolutionaryArchitecture.Fitnet.Contracts.Core; | ||
namespace EvolutionaryArchitecture.Fitnet.Contracts.Application; | ||
|
||
using Core; | ||
|
||
public interface IContractsRepository | ||
{ | ||
Task<Contract?> GetByIdAsync(Guid id, CancellationToken cancellationToken = default); | ||
Task<Contract?> GetPreviousForCustomerAsync(Guid customerId, CancellationToken cancellationToken = default); | ||
Task AddAsync(Contract contract, CancellationToken cancellationToken = default); | ||
Task CommitAsync(CancellationToken cancellationToken = default); | ||
} | ||
} |
1 change: 0 additions & 1 deletion
1
...net.Contracts/Src/Fitnet.Contracts.Application/SignContract/SignContractCommandHandler.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
1 change: 0 additions & 1 deletion
1
....Contracts.Application/TerminateBindingContract/TerminateBindingContractCommandHandler.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
2 changes: 1 addition & 1 deletion
2
.../AddAnnex/BusinessRules/AnnexCanOnlyBeAddedOnlyBeAddedToActiveBindingContractRuleTests.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
34 changes: 34 additions & 0 deletions
34
...n/Fitnet.Contracts/Src/Fitnet.Contracts.Core.UnitTests/Common/Builders/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,34 @@ | ||
namespace EvolutionaryArchitecture.Fitnet.Contracts.Core.UnitTests.PrepareContract; | ||
|
||
using Common; | ||
using SignContract; | ||
|
||
internal sealed class ContractBuilder | ||
{ | ||
internal static ContractBuilder Prepared() => new(); | ||
|
||
private DateTimeOffset? _preparedAt; | ||
|
||
public ContractBuilder PreparedAt(DateTimeOffset preparedAt) | ||
{ | ||
_preparedAt = preparedAt; | ||
return this; | ||
} | ||
|
||
public SignedContractBuilder Signed() => new(Prepare()); | ||
|
||
private Contract Prepare() | ||
{ | ||
var preparedAt = _preparedAt ?? FakeContractDates.PreparedAt; | ||
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.Prepare(); | ||
} |
24 changes: 24 additions & 0 deletions
24
...tnet.Contracts/Src/Fitnet.Contracts.Core.UnitTests/Common/Builders/SignContractBuilder.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,24 @@ | ||
namespace EvolutionaryArchitecture.Fitnet.Contracts.Core.UnitTests.SignContract; | ||
|
||
internal sealed class SignContractBuilder(Contract parentBuilder) | ||
{ | ||
private DateTimeOffset _signDay; | ||
private DateTimeOffset _fakeToday; | ||
|
||
public SignContractBuilder 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(SignContractBuilder builder) => builder.Build(); | ||
} |
9 changes: 9 additions & 0 deletions
9
...en-design/Fitnet.Contracts/Src/Fitnet.Contracts.Core.UnitTests/Common/EntityExtensions.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,9 @@ | ||
namespace EvolutionaryArchitecture.Fitnet.Contracts.Core.UnitTests.Common; | ||
|
||
using DomainDrivenDesign.BuildingBlocks; | ||
|
||
internal static class EntityExtensions | ||
{ | ||
public static TEvent? GetPublishedEvent<TEvent>(this Entity entity) where TEvent : class, IDomainEvent => entity.Events.OfType<TEvent>() | ||
.MinBy(domainEvent => domainEvent.OccuredAt); | ||
} |
7 changes: 7 additions & 0 deletions
7
...n-design/Fitnet.Contracts/Src/Fitnet.Contracts.Core.UnitTests/Common/FakeContractDates.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,7 @@ | ||
namespace EvolutionaryArchitecture.Fitnet.Contracts.Core.UnitTests.Common; | ||
|
||
internal static class FakeContractDates | ||
{ | ||
public static DateTimeOffset PreparedAt => new(2022, 2, 3, 1, 1, 1, TimeSpan.Zero); | ||
public static DateTimeOffset SignDay => new(2022, 1, 3, 1, 1, 1, TimeSpan.Zero); | ||
} |
2 changes: 1 addition & 1 deletion
2
...ore.UnitTests/PrepareContract/BusinessRules/ContractCanBePreparedOnlyForAdultRuleTests.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
2 changes: 1 addition & 1 deletion
2
...sts/PrepareContract/BusinessRules/CustomerMustBeSmallerThanMaximumHeightLimitRuleTests.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
2 changes: 1 addition & 1 deletion
2
...ts.Core.UnitTests/PrepareContract/BusinessRules/PreviousContractHasToBeSignedRuleTests.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
22 changes: 22 additions & 0 deletions
22
...net.Contracts/Src/Fitnet.Contracts.Core.UnitTests/PrepareContract/PrepareContractTests.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,22 @@ | ||
namespace EvolutionaryArchitecture.Fitnet.Contracts.Core.UnitTests.PrepareContract; | ||
|
||
using Common; | ||
using Core.PrepareContract; | ||
|
||
public sealed class PrepareContractTests | ||
{ | ||
private readonly Guid _customerId = Guid.NewGuid(); | ||
private const int CustomerAge = 25; | ||
private const int CustomerHeight = 170; | ||
private readonly DateTimeOffset _preparedAt = new(2022, 2, 3, 1, 1, 1, TimeSpan.Zero); | ||
|
||
[Fact] | ||
internal void Given_prepare_contract_Then_should_raise_contract_prepared_event() | ||
{ | ||
var contract = Contract.Prepare(_customerId, CustomerAge, CustomerHeight, _preparedAt); | ||
|
||
var @event = contract.GetPublishedEvent<ContractPreparedEvent>(); | ||
@event?.CustomerId.Should().Be(_customerId); | ||
@event?.PreparedAt.Should().Be(_preparedAt); | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
...SignContract/BusinessRules/ContractCanOnlyBeSignedWithin30DaysFromPreparationRuleTests.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
2 changes: 1 addition & 1 deletion
2
...acts.Core.UnitTests/SignContract/BusinessRules/ContractMustNotBeAlreadySignedRuleTests.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
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
28 changes: 28 additions & 0 deletions
28
...itnet.Contracts/Src/Fitnet.Contracts.Core.UnitTests/SignContract/SignedContractBuilder.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,28 @@ | ||
namespace EvolutionaryArchitecture.Fitnet.Contracts.Core.UnitTests.SignContract; | ||
|
||
using Common; | ||
|
||
internal sealed class SignedContractBuilder(Contract parentBuilder) | ||
{ | ||
private DateTimeOffset? _signDay; | ||
private DateTimeOffset? _fakeToday; | ||
|
||
public SignedContractBuilder SignedOn(DateTimeOffset signDay, DateTimeOffset fakeToday) | ||
{ | ||
_signDay = signDay; | ||
_fakeToday = fakeToday; | ||
|
||
return this; | ||
} | ||
|
||
private BindingContract Build() | ||
{ | ||
var signDay = _signDay ?? FakeContractDates.SignDay; | ||
var fakeToday = _fakeToday ?? FakeContractDates.SignDay; | ||
var bindingContract = parentBuilder.Sign(signDay, fakeToday); | ||
|
||
return bindingContract; | ||
} | ||
|
||
public static implicit operator BindingContract(SignedContractBuilder builder) => builder.Build(); | ||
} |
2 changes: 1 addition & 1 deletion
2
...BindingContract/BusinessRules/TerminationIsPossibleOnlyAfterThreeMonthsHavePassedTests.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
23 changes: 23 additions & 0 deletions
23
...Fitnet.Contracts.Core.UnitTests/TerminateBindingContract/TerminateBindingContractTests.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.TerminateBindingContract; | ||
|
||
using Common; | ||
using Core.TerminateBindingContract; | ||
using PrepareContract; | ||
|
||
public sealed class TerminateBindingContractTests | ||
{ | ||
private readonly DateTimeOffset _terminatedAt = new(2023, 3, 3, 1, 1, 1, TimeSpan.Zero); | ||
|
||
[Fact] | ||
internal void Given_terminate_binding_contracts_Then_should_raise_binding_contracts() | ||
{ | ||
BindingContract bindingContract = ContractBuilder | ||
.Prepared() | ||
.Signed(); | ||
|
||
bindingContract.Terminate(_terminatedAt); | ||
|
||
var @event = bindingContract.GetPublishedEvent<BindingContractTerminatedEvent>(); | ||
@event?.TerminatedAt.Should().Be(_terminatedAt); | ||
} | ||
} |
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
Oops, something went wrong.