当前位置: 首页>>代码示例>>C#>>正文


C# MyAggregateRoot.InitializeFromHistory方法代码示例

本文整理汇总了C#中MyAggregateRoot.InitializeFromHistory方法的典型用法代码示例。如果您正苦于以下问题:C# MyAggregateRoot.InitializeFromHistory方法的具体用法?C# MyAggregateRoot.InitializeFromHistory怎么用?C# MyAggregateRoot.InitializeFromHistory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MyAggregateRoot的用法示例。


在下文中一共展示了MyAggregateRoot.InitializeFromHistory方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: It_could_not_be_loaded_from_history_when_it_already_contains_uncommitted_events

        public void It_could_not_be_loaded_from_history_when_it_already_contains_uncommitted_events()
        {
            var theAggregate = new MyAggregateRoot();

            theAggregate.MethodThatCausesAnEventThatHasAHandler();
            theAggregate.MethodThatCausesAnEventThatHasAHandler();

            var history = new[] {new HandledEvent(), new HandledEvent()};
            Action act = () => theAggregate.InitializeFromHistory(history);

            act.ShouldThrow<InvalidOperationException>();
        }
开发者ID:sergioazevedo,项目名称:ncqrs,代码行数:12,代码来源:AggregateRootTests.cs

示例2: 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);
        }
开发者ID:sergioazevedo,项目名称:ncqrs,代码行数:14,代码来源:AggregateRootTests.cs

示例3: 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");
        }
开发者ID:sergioazevedo,项目名称:ncqrs,代码行数:14,代码来源:AggregateRootTests.cs

示例4: 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);
        }
开发者ID:sergioazevedo,项目名称:ncqrs,代码行数:8,代码来源:AggregateRootTests.cs

示例5: 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>();
        }
开发者ID:sergioazevedo,项目名称:ncqrs,代码行数:9,代码来源:AggregateRootTests.cs

示例6: Applying_an_event_to_an_agg_root_with_history_should_call_the_event_handler_only_once

        public void Applying_an_event_to_an_agg_root_with_history_should_call_the_event_handler_only_once()
        {
            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);

            var eventHandlerCountAfterInitialization = theAggregate.FooEventHandlerInvokeCount;

            theAggregate.MethodThatCausesAnEventThatHasAHandler();

            theAggregate.FooEventHandlerInvokeCount.Should().Be(eventHandlerCountAfterInitialization + 1);
        }
开发者ID:kajaljatakia,项目名称:ncqrs,代码行数:20,代码来源:AggregateRootTests.cs

示例7: 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 stream = new CommittedEventStream(theAggregate.EventSourceId,
                new CommittedEvent(Guid.NewGuid(), Guid.NewGuid(), theAggregate.EventSourceId, 1, DateTime.UtcNow, new HandledEvent(), new Version(1, 0)),
                new CommittedEvent(Guid.NewGuid(), Guid.NewGuid(), theAggregate.EventSourceId, 2, DateTime.UtcNow, new HandledEvent(), new Version(1, 0)),
                new CommittedEvent(Guid.NewGuid(), Guid.NewGuid(), theAggregate.EventSourceId, 3, DateTime.UtcNow, new HandledEvent(), new Version(1, 0)),
                new CommittedEvent(Guid.NewGuid(), Guid.NewGuid(), theAggregate.EventSourceId, 4, DateTime.UtcNow, new HandledEvent(), new Version(1, 0)),
                new CommittedEvent(Guid.NewGuid(), Guid.NewGuid(), theAggregate.EventSourceId, 5, DateTime.UtcNow, new HandledEvent(), new Version(1, 0)));

            theAggregate.InitializeFromHistory(stream);
        }
开发者ID:VincentSchippefilt,项目名称:ncqrs,代码行数:13,代码来源:AggregateRootTests.cs

示例8: Initiazling_from_wrong_history_with_wrong_sequence_should_throw_exception

        public void Initiazling_from_wrong_history_with_wrong_sequence_should_throw_exception()
        {
            var theAggregate = new MyAggregateRoot();
            const long wrongSequence = 3;
            var stream = new CommittedEventStream(theAggregate.EventSourceId,
                new CommittedEvent(Guid.NewGuid(), Guid.NewGuid(), theAggregate.EventSourceId, wrongSequence, DateTime.UtcNow, new HandledEvent(), new Version(1, 0)));

            Action act = ()=> theAggregate.InitializeFromHistory(stream);
            act.ShouldThrow<InvalidOperationException>().And.Message.Should().Contain("sequence");
        }
开发者ID:VincentSchippefilt,项目名称:ncqrs,代码行数:10,代码来源:AggregateRootTests.cs

示例9: 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();

            var history = new CommittedEventStream(Guid.Empty);

            theAggregate.InitializeFromHistory(history);
        }
开发者ID:VincentSchippefilt,项目名称:ncqrs,代码行数:8,代码来源:AggregateRootTests.cs

示例10: Loading_it_from_history_should_apply_all_events

        public void Loading_it_from_history_should_apply_all_events()
        {
            var aggId = Guid.NewGuid();
            var stream = Prepare.Events(new HandledEvent(), new HandledEvent(), new HandledEvent()).ForSource(aggId);
            var theAggregate = new MyAggregateRoot(aggId);

            theAggregate.InitializeFromHistory(stream);

            theAggregate.FooEventHandlerInvokeCount.Should().Be(3);
        }                
开发者ID:VincentSchippefilt,项目名称:ncqrs,代码行数:10,代码来源:AggregateRootTests.cs


注:本文中的MyAggregateRoot.InitializeFromHistory方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。