public void Then_it_occures_and_applies_to_aggregate() { var aggregate = new TestFutureEventsAggregate(Guid.NewGuid().ToString()); var testValue = "value D"; aggregate.ScheduleInFuture(DateTime.Now.AddSeconds(400), testValue); var futureEventA = aggregate.GetEvent <FutureEventScheduledEvent>(); aggregate.ScheduleInFuture(DateTime.Now.AddSeconds(400), "test value E"); var futureEventOutOfCriteria = aggregate.GetEvents <FutureEventScheduledEvent>().Skip(1).First(); aggregate.CancelFutureEvents(testValue); // Cancelation_event_is_produced() var cancelEvent = aggregate.GetEvent <FutureEventCanceledEvent>(); Assert.Equal(futureEventA.Id, cancelEvent.FutureEventId); //Only_predicate_satisfying_events_are_canceled()` var cancelEvents = aggregate.GetEvents <FutureEventCanceledEvent>(); Assert.True(cancelEvents.All(e => e.FutureEventId != futureEventOutOfCriteria.Id)); // Canceled_event_cannot_be_raised() Assert.Throws <ScheduledEventNotFoundException>(() => aggregate.RaiseScheduledEvent(futureEventA.Id, Guid.NewGuid().ToString())); }
public void Then_nothing_happened() { var aggregate = new TestFutureEventsAggregate(Guid.NewGuid().ToString()); var testValue = "value D"; aggregate.ScheduleInFuture(DateTime.Now.AddSeconds(400), testValue); aggregate.ClearUncommitedEvents(); aggregate.CancelFutureEvents("will not be found in any future event"); //No_events_were_produced() Assert.Empty(aggregate.GetEvents <DomainEvent>()); }
public void When_scheduling_future_event() { var aggregate = new TestFutureEventsAggregate(Guid.NewGuid().ToString()); aggregate.ScheduleInFuture(DateTime.Now.AddSeconds(400), "value D"); aggregate.ClearUncommitedEvents(); //Then_raising_event_with_wrong_id_throws_an_error() Assert.Throws <ScheduledEventNotFoundException>(() => aggregate.RaiseScheduledEvent(Guid.NewGuid() .ToString(), Guid.NewGuid() .ToString())); //Then_raising_event_with_wrong_id_does_not_produce_new_events() try { aggregate.RaiseScheduledEvent(Guid.NewGuid().ToString(), Guid.NewGuid().ToString()); } catch { //intentionally left empty } Assert.Empty(aggregate.GetEvents()); }