public void can_build_aggregation_step_for_an_apply_method()
        {
            Expression<Action<QuestParty, MembersJoined>> apply = (p, j) => p.Apply(j);


            var joined = ReflectionHelper.GetMethod<QuestParty>(x => x.Apply(new MembersJoined()));

            var joinedStep = new AggregationStep<QuestParty, MembersJoined>(joined);

            var party = new QuestParty();
            var joinedEvent = new MembersJoined {Members = new []{"Wolverine", "Cyclops", "Nightcrawler"}};

            joinedStep.Apply(party, joinedEvent);

            party.Members.ShouldHaveTheSameElementsAs(joinedEvent.Members);
        }
Beispiel #2
0
        public void find_when_stream_is_not_new()
        {
            var session = Substitute.For <IDocumentSession>();
            var id      = Guid.NewGuid();

            var persisted = new QuestParty {
                Id = id
            };

            var finder = new AggregateFinder <QuestParty>();

            session.Load <QuestParty>(id).Returns(persisted);

            finder.Find(new EventStream(id, false), session)
            .ShouldBeTheSameAs(persisted);
        }
Beispiel #3
0
        public async Task find_when_stream_is_not_new_async()
        {
            var id = Guid.NewGuid();

            var persisted = new QuestParty {
                Id = id
            };

            theSession.Store(persisted);
            theSession.SaveChanges();

            var finder = new AggregateFinder <QuestParty>();

            (await finder.FindAsync(new EventStream(id, false), theSession, new CancellationToken()))
            .ShouldBeTheSameAs(persisted);
        }
Beispiel #4
0
        public void can_build_aggregation_step_for_an_apply_method()
        {
            Expression <Action <QuestParty, MembersJoined> > apply = (p, j) => p.Apply(j);

            var joined = ReflectionHelper.GetMethod <QuestParty>(x => x.Apply(new MembersJoined()));

            var joinedStep = new AggregationStep <QuestParty, MembersJoined>(joined);

            var party       = new QuestParty();
            var joinedEvent = new MembersJoined {
                Members = new[] { "Wolverine", "Cyclops", "Nightcrawler" }
            };

            joinedStep.Apply(party, joinedEvent);

            party.Members.ShouldHaveTheSameElementsAs(joinedEvent.Members);
        }