本文整理汇总了C#中MyAggregateRoot类的典型用法代码示例。如果您正苦于以下问题:C# MyAggregateRoot类的具体用法?C# MyAggregateRoot怎么用?C# MyAggregateRoot使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MyAggregateRoot类属于命名空间,在下文中一共展示了MyAggregateRoot类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: It_should_initialize_with_a_new_id_given_by_the_generator_from_the_environment
public void It_should_initialize_with_a_new_id_given_by_the_generator_from_the_environment()
{
var generator = MockRepository.GenerateMock<IUniqueIdentifierGenerator>();
NcqrsEnvironment.SetDefault<IUniqueIdentifierGenerator>(generator);
var theAggregate = new MyAggregateRoot();
generator.AssertWasCalled(g => g.GenerateNewId());
}
示例2: Applying_an_event_should_at_it_to_the_uncommited_events
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);
}
示例3: Applying_an_event_should_not_effect_the_initial_version
public void Applying_an_event_should_not_effect_the_initial_version()
{
using (NcqrsEnvironment.Get<IUnitOfWorkFactory>().CreateUnitOfWork())
{
var theAggregate = new MyAggregateRoot();
theAggregate.InitialVersion.Should().Be(0);
theAggregate.MethodThatCausesAnEventThatHasAHandler();
theAggregate.InitialVersion.Should().Be(0);
theAggregate.MethodThatCausesAnEventThatHasAHandler();
theAggregate.InitialVersion.Should().Be(0);
theAggregate.MethodThatCausesAnEventThatHasAHandler();
}
}
示例4: Accepting_the_changes_should_clear_the_uncommitted_events
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();
}
示例5: Applying_an_event_should_at_it_to_the_uncommited_events
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);
}
}
示例6: Accepting_the_changes_should_set_the_initial_version_to_the_new_version
public void Accepting_the_changes_should_set_the_initial_version_to_the_new_version()
{
var theAggregate = new MyAggregateRoot();
theAggregate.MethodThatCausesAnEventThatHasAHandler();
theAggregate.MethodThatCausesAnEventThatHasAHandler();
theAggregate.MethodThatCausesAnEventThatHasAHandler();
theAggregate.MethodThatCausesAnEventThatHasAHandler();
theAggregate.MethodThatCausesAnEventThatHasAHandler();
theAggregate.InitialVersion.Should().Be(0);
theAggregate.AcceptChanges();
theAggregate.InitialVersion.Should().Be(5);
}
示例7: Applying_an_event_should_affect_the_version
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();
}
示例8: Accepting_the_changes_should_clear_the_uncommitted_events
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();
}
}
示例9: Accepting_the_changes_should_set_the_initial_version_to_the_new_version
public void Accepting_the_changes_should_set_the_initial_version_to_the_new_version()
{
using (NcqrsEnvironment.Get<IUnitOfWorkFactory>().CreateUnitOfWork())
{
var theAggregate = new MyAggregateRoot();
theAggregate.MethodThatCausesAnEventThatHasAHandler();
theAggregate.MethodThatCausesAnEventThatHasAHandler();
theAggregate.MethodThatCausesAnEventThatHasAHandler();
theAggregate.MethodThatCausesAnEventThatHasAHandler();
theAggregate.MethodThatCausesAnEventThatHasAHandler();
theAggregate.InitialVersion.Should().Be(0);
theAggregate.AcceptChanges();
theAggregate.InitialVersion.Should().Be(5);
}
}
示例10: Save_test
public void Save_test()
{
using (var work = NcqrsEnvironment.Get<IUnitOfWorkFactory>().CreateUnitOfWork())
{
var store = MockRepository.GenerateMock<IEventStore>();
var bus = MockRepository.GenerateMock<IEventBus>();
var aggregate = new MyAggregateRoot();
aggregate.Foo();
aggregate.Bar();
store.Expect(s => s.Save(aggregate));
bus.Expect(b => b.Publish((IEnumerable<IEvent>) null)).IgnoreArguments();
var repository = new DomainRepository(store, bus);
repository.Save(aggregate);
bus.VerifyAllExpectations();
store.VerifyAllExpectations();
}
}
示例11: Initiazling_from_wrong_history_with_wrong_sequence_should_throw_exception2
public void Initiazling_from_wrong_history_with_wrong_sequence_should_throw_exception2()
{
var theAggregate = new MyAggregateRoot();
long wrongSequence = 8;
var event1 = new HandledEvent(Guid.NewGuid(), theAggregate.EventSourceId, 0, DateTime.UtcNow);
var event2 = new HandledEvent(Guid.NewGuid(), theAggregate.EventSourceId, 1, DateTime.UtcNow);
var event3 = new HandledEvent(Guid.NewGuid(), theAggregate.EventSourceId, wrongSequence, DateTime.UtcNow);
IEnumerable<SourcedEvent> history = new[] { event1, event2, event3 };
Action act = () => theAggregate.InitializeFromHistory(history);
act.ShouldThrow<InvalidOperationException>().And.Message.Should().Contain("sequence");
}
示例12: Initiazling_from_history_with_correct_sequence_should_not_throw_exception
public void Initiazling_from_history_with_correct_sequence_should_not_throw_exception()
{
var theAggregate = new MyAggregateRoot();
var event1 = new HandledEvent(Guid.NewGuid(), theAggregate.EventSourceId, 1, DateTime.UtcNow);
var event2 = new HandledEvent(Guid.NewGuid(), theAggregate.EventSourceId, 2, DateTime.UtcNow);
var event3 = new HandledEvent(Guid.NewGuid(), theAggregate.EventSourceId, 3, DateTime.UtcNow);
var event4 = new HandledEvent(Guid.NewGuid(), theAggregate.EventSourceId, 4, DateTime.UtcNow);
var event5 = new HandledEvent(Guid.NewGuid(), theAggregate.EventSourceId, 5, DateTime.UtcNow);
IEnumerable<SourcedEvent> history = new[] { event1, event2, event3, event4, event5 };
theAggregate.InitializeFromHistory(history);
}
示例13: Initializing_from_history_should_throw_an_exception_when_the_history_was_null
public void Initializing_from_history_should_throw_an_exception_when_the_history_was_null()
{
IEnumerable<SourcedEvent> nullHistory = null;
var theAggregate = new MyAggregateRoot();
Action act = () => theAggregate.InitializeFromHistory(nullHistory);
act.ShouldThrow<ArgumentNullException>();
}
示例14: Initializing_from_history_should_not_throw_an_exception_when_the_history_was_empty
public void Initializing_from_history_should_not_throw_an_exception_when_the_history_was_empty()
{
var theAggregate = new MyAggregateRoot();
IEnumerable<SourcedEvent> history = new SourcedEvent[0];
theAggregate.InitializeFromHistory(history);
}
示例15: Loading_it_from_history_should_apply_all_events
public void Loading_it_from_history_should_apply_all_events()
{
var aggId = Guid.NewGuid();
var history = new[] { new HandledEvent(Guid.NewGuid(), aggId, 1, DateTime.UtcNow), new HandledEvent(Guid.NewGuid(), aggId, 2, DateTime.UtcNow), new HandledEvent(Guid.NewGuid(), aggId, 3, DateTime.UtcNow) };
var theAggregate = new MyAggregateRoot(history);
theAggregate.FooEventHandlerInvokeCount.Should().Be(3);
}