예제 #1
0
        public void EventsHaveCorrectAggregateType()
        {
            Guid     guid        = Guid.NewGuid();
            DateTime createdDate = new DateTime(2020, 12, 25);
            SimpleTextAggregateCreatedEvent simpleEvent = new SimpleTextAggregateCreatedEvent(Guid.NewGuid(), guid, createdDate, "foo");

            Assert.Equal("SimpleTextAggregate", simpleEvent.AggregateType);

            LibraryItemCreatedEvent libraryItemEvent = _eventFactory.GetCreatedEvent(guid, "foo", "bar");

            Assert.Equal("LibraryItem", libraryItemEvent.AggregateType);
        }
예제 #2
0
        public void TestSimpleTextAggregate()
        {
            Guid     guid        = Guid.NewGuid();
            DateTime createdDate = new DateTime(2020, 12, 25);

            SimpleTextAggregateCreatedEvent createdEvent = new SimpleTextAggregateCreatedEvent(Guid.NewGuid(), guid, createdDate, "foo");

            SimpleTextAggregate agg = new SimpleTextAggregate();

            agg.Apply(new List <IEvent>()
            {
                createdEvent
            });

            Assert.Equal(guid, agg.AggregateId);
            Assert.Equal("foo", agg.Text);

            agg.Apply(new SimpleTextAggregateUpdatedEvent(Guid.NewGuid(), guid, DateTime.UtcNow, "bar"));

            Assert.Equal("bar", agg.Text);
        }