示例#1
0
        public async Task Aggregate_Should_Be_Saved_In_Storage_Test()
        {
            var provider = Configure();

            var id        = Guid.NewGuid();
            var aggregate = new TestAggregate(id, "Lorem");

            var session = provider.GetService <ISession>();
            await session.Add(aggregate);

            await session.Commit(id);

            var storage = provider.GetService <IAggregateStorage>();
            var result  = await storage.Get <TestAggregate>(id, 0);

            Assert.Equal("Lorem", result.TestProperty);
        }
示例#2
0
        public async Task Aggregate_Events_Should_Be_Saved_Test()
        {
            var provider  = Configure();
            var id        = Guid.NewGuid();
            var aggregate = new TestAggregate(id, "Lorem");

            var storage = provider.GetService <IAggregateStorage>();
            await storage.Save(aggregate, -2);

            var eventstore = provider.GetService <IEventStore>();

            var events = await eventstore.Get(id);

            Assert.Equal(1, events.Count);

            var @event = events.First() as TestAggregateCreatedEvent;

            Assert.Equal("Lorem", @event.TestProperty);
        }