/// <summary> /// Initializes a new instance of the <see cref="T:System.Object"/> class. /// </summary> public Scenario(ScenarioBuilder builder) { if (builder == null) { throw new ArgumentNullException("builder"); } this.builder = builder; disposables.Add(builder.EventBus.Errors.Subscribe(e => eventHandlingErrors.Add(e))); clockName = builder.Configuration .Properties .IfContains("CommandSchedulerClockName") .And() .IfTypeIs <string>() .ElseDefault(); Clock.Current .IfTypeIs <VirtualClock>() .ThenDo(c => { subscribedToVirtualClock = true; disposables.Add(c.Subscribe(onNext: t => AdvanceClock(t).Wait())); }); }
/// <summary> /// Initializes a new instance of the <see cref="T:System.Object"/> class. /// </summary> public Scenario(ScenarioBuilder builder) { if (builder == null) { throw new ArgumentNullException("builder"); } this.builder = builder; disposables.Add(builder.EventBus.Errors.Subscribe(e => eventHandlingErrors.Add(e))); clockName = builder.Configuration .Properties .IfContains("CommandSchedulerClockName") .And() .IfTypeIs <string>() .ElseDefault(); // subscribe to VirtualClock movements and advance the scheduler clock accordingly Clock.Current .IfTypeIs <VirtualClock>() .ThenDo(virtualClock => { subscribedToVirtualClock = true; }); }
/// <summary> /// Initializes a new instance of the <see cref="AggregateBuilder{TAggregate}"/> class. /// </summary> /// <param name="aggregateId">The aggregate id to be used for this aggregate.</param> /// <param name="scenarioBuilder">The associated scenario builder.</param> /// <exception cref="System.ArgumentNullException">scenarioBuilder</exception> public AggregateBuilder(Guid aggregateId, ScenarioBuilder scenarioBuilder) { if (scenarioBuilder == null) { throw new ArgumentNullException(nameof(scenarioBuilder)); } this.aggregateId = aggregateId; this.scenarioBuilder = scenarioBuilder; }
/// <summary> /// Initializes a new instance of the <see cref="T:System.Object"/> class. /// </summary> public Scenario(ScenarioBuilder builder) { if (builder == null) { throw new ArgumentNullException(nameof(builder)); } this.builder = builder; disposables.Add(builder.EventBus.Errors.Subscribe(e => eventHandlingErrors.Add(e))); // subscribe to VirtualClock movements and advance the scheduler clock accordingly Clock.Current .IfTypeIs <VirtualClock>() .ThenDo(virtualClock => { subscribedToVirtualClock = true; }); }
/// <summary> /// Gets the time at which the scenario's timeline begins. /// </summary> /// <remarks>This is the earliest of either the virtual clock time or the earliest event in the <see cref="ScenarioBuilder.InitialEvents" /> sequence.</remarks> public static DateTimeOffset StartTime(this ScenarioBuilder scenarioBuilder) { var earliestEvent = scenarioBuilder.InitialEvents .OrderBy(e => e.Timestamp) .FirstOrDefault(); var now = VirtualClock.Current.Now(); if (earliestEvent == null) { return(now); } return(now.UtcTicks < earliestEvent.Timestamp.UtcTicks ? now : earliestEvent.Timestamp); }