• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# MyAggregateRoot类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



MyAggregateRoot类属于命名空间,在下文中一共展示了MyAggregateRoot类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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());
        }
开发者ID:VincentSchippefilt,项目名称:ncqrs,代码行数:9,代码来源:AggregateRootTests.cs


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


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


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


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


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


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


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


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


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


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


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


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


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


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


示例16: It_should_initialize_with_no_uncommited_events

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

            theAggregate.GetUncommittedEvents().Count().Should().Be(0);
        }
开发者ID:sergioazevedo,项目名称:ncqrs,代码行数:6,代码来源:AggregateRootTests.cs


示例17: Applying_an_event_that_is_already_owned_by_another_source_should_cause_an_exception

        public void Applying_an_event_that_is_already_owned_by_another_source_should_cause_an_exception()
        {
            var theEvent = new HandledEvent();
            theEvent.OverrideAggregateRootId(Guid.NewGuid());
            var theAggregate = new MyAggregateRoot();

            Action act = () => theAggregate.ApplyEvent(theEvent);

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


示例18: Applying_an_event_should_the_the_version

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


示例19: Applying_an_event_should_call_the_event_handler_only_once

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

            theAggregate.MethodThatCausesAnEventThatHasAHandler();

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


示例20: Applying_an_event_should_not_effect_the_initial_version

        public void Applying_an_event_should_not_effect_the_initial_version()
        {
            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();
        }
开发者ID:kajaljatakia,项目名称:ncqrs,代码行数:11,代码来源:AggregateRootTests.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# MyCharacterController类代码示例发布时间:2022-05-24
下一篇:
C# MxWeiXinPF类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap