public void Applying_an_event_should_at_it_to_the_uncommited_events() { var theAggregate = new MyAggregateRoot(); theAggregate.MethodThatCausesAnEventThatHasAHandler(); theAggregate.GetUncommittedEvents().Count().Should().Be(1); theAggregate.MethodThatCausesAnEventThatHasAHandler(); theAggregate.GetUncommittedEvents().Count().Should().Be(2); }
public void Applying_an_event_should_at_it_to_the_uncommited_events() { using (NcqrsEnvironment.Get<IUnitOfWorkFactory>().CreateUnitOfWork()) { var theAggregate = new MyAggregateRoot(); theAggregate.MethodThatCausesAnEventThatHasAHandler(); theAggregate.GetUncommittedEvents().Count().Should().Be(1); theAggregate.MethodThatCausesAnEventThatHasAHandler(); theAggregate.GetUncommittedEvents().Count().Should().Be(2); } }
public void Applying_an_event_should_affect_the_version() { var theAggregate = new MyAggregateRoot(); theAggregate.Version.Should().Be(0); theAggregate.MethodThatCausesAnEventThatHasAHandler(); theAggregate.Version.Should().Be(1); theAggregate.GetUncommittedEvents().Last().EventSequence.Should().Be(1); theAggregate.MethodThatCausesAnEventThatHasAHandler(); theAggregate.Version.Should().Be(2); theAggregate.GetUncommittedEvents().Last().EventSequence.Should().Be(2); theAggregate.MethodThatCausesAnEventThatHasAHandler(); }
public void Getting_the_uncommitted_via_the_IEventSource_interface_should_return_the_same_as_directly() { var theAggregate = new MyAggregateRoot(); theAggregate.MethodThatCausesAnEventThatHasAHandler(); theAggregate.MethodThatCausesAnEventThatHasAHandler(); var directResult = theAggregate.GetUncommittedEvents(); var viaInterfaceResult = ((IEventSource)theAggregate).GetUncommittedEvents(); directResult.Should().BeEquivalentTo(viaInterfaceResult); }
public void Accepting_the_changes_should_clear_the_uncommitted_events() { var theAggregate = new MyAggregateRoot(); theAggregate.MethodThatCausesAnEventThatHasAHandler(); theAggregate.MethodThatCausesAnEventThatHasAHandler(); theAggregate.MethodThatCausesAnEventThatHasAHandler(); theAggregate.MethodThatCausesAnEventThatHasAHandler(); theAggregate.MethodThatCausesAnEventThatHasAHandler(); theAggregate.AcceptChanges(); theAggregate.GetUncommittedEvents().Should().BeEmpty(); }
public void Accepting_the_changes_should_clear_the_uncommitted_events() { using (NcqrsEnvironment.Get<IUnitOfWorkFactory>().CreateUnitOfWork()) { var theAggregate = new MyAggregateRoot(); theAggregate.MethodThatCausesAnEventThatHasAHandler(); theAggregate.MethodThatCausesAnEventThatHasAHandler(); theAggregate.MethodThatCausesAnEventThatHasAHandler(); theAggregate.MethodThatCausesAnEventThatHasAHandler(); theAggregate.MethodThatCausesAnEventThatHasAHandler(); theAggregate.AcceptChanges(); theAggregate.GetUncommittedEvents().Should().BeEmpty(); } }
public void It_should_initialize_with_no_uncommited_events() { var theAggregate = new MyAggregateRoot(); theAggregate.GetUncommittedEvents().Count().Should().Be(0); }
public void Getting_the_uncommitted_via_the_IEventSource_interface_should_return_the_same_as_directly() { var theAggregate = new MyAggregateRoot(); theAggregate.MethodThatCausesAnEventThatHasAHandler(); theAggregate.MethodThatCausesAnEventThatHasAHandler(); var directResult = theAggregate.GetUncommittedEvents(); var viaInterfaceResult = ((IEventSource) theAggregate).GetUncommittedEvents(); directResult.Should().BeEquivalentTo(viaInterfaceResult); }
public void Applying_an_event_should_the_the_version() { using (NcqrsEnvironment.Get<IUnitOfWorkFactory>().CreateUnitOfWork()) { var theAggregate = new MyAggregateRoot(); theAggregate.Version.Should().Be(0); theAggregate.MethodThatCausesAnEventThatHasAHandler(); theAggregate.Version.Should().Be(1); theAggregate.GetUncommittedEvents().Last().EventSequence.Should().Be(1); theAggregate.MethodThatCausesAnEventThatHasAHandler(); theAggregate.Version.Should().Be(2); theAggregate.GetUncommittedEvents().Last().EventSequence.Should().Be(2); theAggregate.MethodThatCausesAnEventThatHasAHandler(); } }