示例#1
0
        public void EntityShouldBePersisted()
        {
            //Given
            var mockEntity = new MockEntityOne();

            //When
            mockEntity.ApplyEventChanges();
            //Then
            Assert.False(mockEntity.IsTransient());
        }
示例#2
0
        public void FooItemShouldBeAdded()
        {
            //Given
            var mockEntity = new MockEntityOne();

            mockEntity.AddFoos("foo1");
            mockEntity.AddFoos("foo2");
            //When
            mockEntity.ApplyEventChanges();
            //Then
            Assert.True(mockEntity.Foos.Contains("foo1") && mockEntity.Foos.Contains("foo2"));
        }
示例#3
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);
        }
示例#4
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");
        }
示例#5
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);
        }