forked from pjvds/ncqrs
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a489756
commit 2b2f467
Showing
6 changed files
with
84 additions
and
215 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
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,58 @@ | ||
using System.Collections.Generic; | ||
using Ncqrs.Commanding; | ||
using Ncqrs.Eventing; | ||
using Ncqrs.Spec.Fakes; | ||
|
||
namespace Ncqrs.Spec | ||
{ | ||
|
||
[Specification] | ||
public abstract class DomainTestFixture<TCommand> | ||
: BaseTestFixture | ||
where TCommand : ICommand | ||
{ | ||
|
||
private EnvironmentConfigurationWrapper _configuration; | ||
|
||
protected IEnumerable<UncommittedEvent> PublishedEvents { get; private set; } | ||
|
||
protected TCommand ExecutedCommand { get; private set; } | ||
|
||
protected abstract TCommand WhenExecuting(); | ||
|
||
protected abstract void Execute(TCommand command); | ||
|
||
protected virtual void SetupDependencies() | ||
{ | ||
_configuration = new EnvironmentConfigurationWrapper(); | ||
RegisterFakesInConfiguration(_configuration); | ||
_configuration.Push(); | ||
} | ||
|
||
protected virtual void RegisterFakesInConfiguration(EnvironmentConfigurationWrapper configuration) | ||
{ | ||
} | ||
|
||
protected override void Given() | ||
{ | ||
SetupDependencies(); | ||
PublishedEvents = new UncommittedEvent[0]; | ||
ExecutedCommand = WhenExecuting(); | ||
} | ||
|
||
protected override void When() | ||
{ | ||
using (var ctx = new EventContext()) | ||
{ | ||
Execute(ExecutedCommand); | ||
PublishedEvents = ctx.Events; | ||
} | ||
} | ||
|
||
protected override void Finally() | ||
{ | ||
_configuration.Pop(); | ||
} | ||
|
||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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