//TODO: refactor this method public IAggregateRoot <TEventType> Apply(TEventType evnt) { var restoredEntity = _eventStream.Aggregate(_entity, (acc, next) => When(acc.Appled().Result(), (TEventType)next)); var entity = restoredEntity == null ? _entity : new Applied <TEntity>(restoredEntity.Appled().Result()); var applied = entity.Appled(); return(new FakeAggregateRoot <TEntity, TEventType>( When, When(applied.Result(), evnt), applied .Events() .Concat(new [] { (IDomainEvent)evnt.Content() }) )); }