Пример #1
0
        public void can_set_aggregator_through_extension_methods_and_strategy()
        {
            var theGraph = new EventGraph(new StoreOptions());

            theGraph.UseAggregatorLookup(AggregationLookupStrategy.UsePublicApply);

            var aggregator = theGraph.AggregateFor <QuestParty>();

            var stream = StreamAction.Start(Guid.NewGuid(), new object[] { new QuestStarted {
                                                                               Name = "Destroy the Ring"
                                                                           } });

            var party = aggregator.Build(stream.Events, null);

            party.Name.ShouldBe("Destroy the Ring");
        }
Пример #2
0
        public void can_lookup_private_apply_methods()
        {
            var theGraph = new EventGraph(new StoreOptions());

            theGraph.UseAggregatorLookup(new AggregatorLookup(type => typeof(AggregatorApplyPrivate <>).CloseAndBuildAs <IAggregator>(type)));

            var aggregator = theGraph.AggregateFor <AggregateWithPrivateEventApply>();

            var stream = StreamAction.Append(Guid.NewGuid(), new[] { new QuestStarted {
                                                                         Name = "Destroy the Ring"
                                                                     } });

            var party = aggregator.Build(stream.Events, null);

            party.Name.ShouldBe("Destroy the Ring");
        }
Пример #3
0
        public void can_set_private_apply_aggregator_through_extension_methods_and_strategy()
        {
            var theGraph = new EventGraph(new StoreOptions());

            // SAMPLE: register-custom-aggregator-lookup
            // Registering an aggregator lookup that provides aggregator supporting private Apply([Event Type]) methods
            theGraph.UseAggregatorLookup(AggregationLookupStrategy.UsePrivateApply);
            // ENDSAMPLE

            var aggregator = theGraph.AggregateFor <AggregateWithPrivateEventApply>();

            var stream = StreamAction.Append(Guid.NewGuid(), new object[] { new QuestStarted {
                                                                                Name = "Destroy the Ring"
                                                                            } });

            var party = aggregator.Build(stream.Events, null);

            party.Name.ShouldBe("Destroy the Ring");
        }
Пример #4
0
        public void can_set_public_and_private_apply_aggregator_through_extension_methods_and_strategy()
        {
            var theGraph = new EventGraph(new StoreOptions());

            theGraph.UseAggregatorLookup(AggregationLookupStrategy.UsePublicAndPrivateApply);

            var aggregator = theGraph.AggregateFor <AggregateWithPrivateEventApply>();

            var stream = StreamAction.Append(Guid.NewGuid(), new object[] { new QuestStarted {
                                                                                Name = "Destroy the Ring"
                                                                            } });

            var party = aggregator.Build(stream.Events, null);

            party.Name.ShouldBe("Destroy the Ring");

            stream.Add(new QuestEnded {
                Name = "Ring Destroyed"
            });
            var party2 = aggregator.Build(stream.Events, null);

            party2.Name.ShouldBe("Ring Destroyed");
        }
Пример #5
0
 public CustomAggregatorLookupTests()
 {
     theGraph.UseAggregatorLookup(new AggregatorLookup(type => typeof(AggregatorUsePrivateApply <>).CloseAndBuildAs <IAggregator>(type)));
 }