Пример #1
0
        public void EntityShouldBeCopied()
        {
            var mockEntity = new MockEntityOne();

            mockEntity.ApplyEventChanges();

            var events = new List <EventStream>(mockEntity.AllEvents);

            var copiedMockEntity = new MockEntityOne();

            copiedMockEntity.LoadFromHistory(events);

            Assert.True(copiedMockEntity == mockEntity);
        }
Пример #2
0
        public void CopiedEntityAndOriginalEntityShouldHaveTheSameEvents()
        {
            var mockEntity = new MockEntityOne();

            mockEntity.AddFoos("foo1");
            mockEntity.SetBar(2);
            mockEntity.ApplyEventChanges();

            var events = new List <EventStream>(mockEntity.AllEvents);

            var copiedMockEntity = new MockEntityOne();

            copiedMockEntity.LoadFromHistory(events);

            Assert.True(copiedMockEntity.AllEvents
                        .Any(eventStream => eventStream.GetType() == typeof(FoosAdded)), "FoosAdded event is not in the copiedMockEntity");
        }
Пример #3
0
        public void CopiedEntityShouldHaveHigherVersionThanTheOriginalEntity()
        {
            var mockEntity = new MockEntityOne();

            mockEntity.AddFoos("foo1");
            mockEntity.AddFoos("foo2");
            mockEntity.SetBar(2);

            mockEntity.ApplyEventChanges();

            var events = new List <EventStream>(mockEntity.AllEvents);

            var copiedMockEntity = new MockEntityOne();

            copiedMockEntity.LoadFromHistory(events);

            Assert.True(mockEntity.Version < copiedMockEntity.Version);
        }