public async Task Handle_EntityDefinitionDeletedEvent_RemovesValuesOfEntity()
        {
            // arrange
            var initialProject = this.CreateProject();
            var initialEntity  = initialProject.Entities.First();
            var initialEntry   = initialEntity.Entries.First();

            var message = new EntityDefinitionDeleted
            {
                Id        = initialProject.Id,
                EntityId  = initialEntity.Id,
                Version   = 2,
                TimeStamp = DateTimeOffset.Now
            };

            var target = new ReadModelEventHandler(this.context.DbContext, this.context.Mapper);

            // act
            await target.Handle(message);

            // assert
            var values = this.context.DbContext.Values.Where(p => p.EntryId == initialEntry.Id);

            Assert.Empty(values);
        }
        public async Task Handle_EntityDefinitionDeletedEvent_UpdatesProjectVersionTracking()
        {
            // arrange
            var initialProject = this.CreateProject();
            var initialEntity  = initialProject.Entities.First();

            var message = new EntityDefinitionDeleted
            {
                Id        = initialProject.Id,
                EntityId  = initialEntity.Id,
                Version   = 2,
                TimeStamp = DateTimeOffset.Now
            };

            var target = new ReadModelEventHandler(this.context.DbContext, this.context.Mapper);

            // act
            await target.Handle(message);

            // assert
            var project = this.context.DbContext.Projects.First(p => p.Id == message.Id);

            Assert.Equal(message.Id, project.Id);
            Assert.Equal(message.Version, project.Version);
            Assert.Equal(message.TimeStamp, project.TimeStamp);
        }
示例#3
0
 private void OnEntityDefinitionDeleted(EntityDefinitionDeleted e)
 {
     if (this.entities.ContainsKey(e.EntityId))
     {
         this.entities.Remove(e.EntityId);
     }
 }
        public async Task Handle(EntityDefinitionDeleted message)
        {
            message.ArgumentNotNull(nameof(message));

            await this.DeleteEntityAsync <EntityDefinitionDeleted, ConfigurationEntity>(message, m => m.EntityId);

            await this.dbContext.SaveChangesAsync();
        }
        private void OnEntityDefinitionDeleted(EntityDefinitionDeleted e)
        {
            EntityDefinition entity = this.entities.FirstOrDefault(i => i.Id == e.EntityId);

            if (entity != null)
            {
                this.entities.Remove(entity);
            }
        }
示例#6
0
        public void DeleteEntityDefinition(Guid entityId)
        {
            var e = new EntityDefinitionDeleted
            {
                Id       = this.Id,
                EntityId = entityId
            };

            this.ApplyChange(e);
        }
        public async Task Handle_EntityDefinitionDeletedEvent_RemovesEntity()
        {
            // arrange
            var initialProject = this.CreateProject();
            var initialEntity  = initialProject.Entities.First();

            var message = new EntityDefinitionDeleted
            {
                Id        = initialProject.Id,
                EntityId  = initialEntity.Id,
                Version   = 2,
                TimeStamp = DateTimeOffset.Now
            };

            var target = new ReadModelEventHandler(this.context.DbContext, this.context.Mapper);

            // act
            await target.Handle(message);

            // assert
            var entity = this.context.DbContext.Entities.FirstOrDefault(p => p.Id == message.EntityId);

            Assert.Null(entity);
        }
示例#8
0
 private void Apply(EntityDefinitionDeleted e)
 {
     this.eventAggregator.Publish(e);
 }