Show / Hide Table of Contents

Class AggregateRootTest<TAggregateRoot>

Represents a base class for performing Given-When-Then tests on IAggregateRoot.

Inheritance
Object
AggregateRootTest<TAggregateRoot>
Inherited Members
System.Object.ToString()
Object.Equals(Object)
System.Object.Equals(System.Object, System.Object)
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
Object.MemberwiseClone()
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

Gets an Exception that was caught during execution of When().

Declaration
protected Exception CaughtException { get; }
Property Value
Exception

ProducedEvents

Gets the IEvent that was produced during execution of When().

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()

Extension Methods

ObjectExtensions.DeepClone<T>(T)
AnnotationsExtensions.IsValid(Object)
Back to top Generated by DocFX