Class AggregateRootTest<TAggregateRoot>
Represents a base class for performing Given-When-Then tests on IAggregateRoot.
Inherited Members
Namespace: IRM.Domain.Tests
Assembly: IRM.dll
Syntax
public abstract class AggregateRootTest<TAggregateRoot>
where TAggregateRoot : class, IEventSourced
Type Parameters
TAggregateRoot
The type of aggregate to test. |
Constructors
AggregateRootTest()
Initializes a new instance of the AggregateRootTest<TAggregateRoot> class with ConstructAggregatesWithDefaultConstructor for constructing the aggregate.
Declaration
protected AggregateRootTest()
AggregateRootTest(IConstructObject)
Initializes a new instance of the AggregateRootTest<TAggregateRoot> class with a IConstructAggregates for constructing the aggregate.
Declaration
protected AggregateRootTest(IConstructObject aggregateConstructor)
Parameters
IConstructObject
aggregateConstructor
|
Properties
CaughtException
ProducedEvents
Declaration
protected IEnumerable<IEvent> ProducedEvents { get; }
Property Value
IEnumerable<IEvent>
|
SubjectUnderTest
Gets or sets the IAggregateRoot instance to perform the tests for.
Declaration
protected TAggregateRoot SubjectUnderTest { get; set; }
Property Value
TAggregateRoot
|
Remarks
If you don't want to build the aggregate from events in Given(), then you can set SubjectUnderTest to the instance that you want to perform tests for.
Methods
Finally()
Override this method if you want to do any clean up after the execution of When().
Declaration
protected virtual void Finally()
Given()
Override this method to initialize the aggregate root to the state you want to test from.
Declaration
protected virtual IEnumerable<Event> Given()
Returns
IEnumerable<Event>
Zero, one or more events used to build up the aggregate. |
Remarks
You can optionally set the SubjectUnderTest to an instance with correct state and then just return this base class implementation for Given.
Setup()
Override this method and mark it with the TestInitializeAttribute. You can optionally set SubjectUnderTest in this method, even if doing it in Given() is a little bit more clear.
Declaration
public virtual void Setup()
When()
Override this method and do the action you want to test.
Declaration
protected abstract void When()