public async Task Handle_ConfigurationEntryDeletedEvent_DeletesValues() { // arrange var initialProject = this.CreateProject(); var initialEntity = initialProject.Entities.First(); var initialEntry = initialEntity.Entries.First(); var message = new ConfigurationEntryDeleted { Id = initialProject.Id, EntryId = initialEntry.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(e => e.EntryId == initialEntry.Id); Assert.Empty(values); }
public async Task Handle_EntityDefinitionAddedEvent_UpdatesProjectVersionTracking() { // arrange var initialProject = this.CreateProject(); var message = new EntityDefinitionAdded { Id = initialProject.Id, EntityId = Guid.NewGuid(), Version = 2, TimeStamp = DateTimeOffset.Now, Name = "New Entity Name", Description = "new Entity Description" }; 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); }
public async Task Handle_ConfigurationEntryModifiedEvent_UpdatesValues() { // arrange var initialProject = this.CreateProject(); var initialEntity = initialProject.Entities.First(); var initialEntry = initialEntity.Entries.First(); var message = new ConfigurationEntryModified { Id = initialProject.Id, EntryId = initialEntry.Id, Values = new Dictionary <Guid, object> { { initialEntity.Properties.ElementAt(0).Id, "TestValue1" }, { initialEntity.Properties.ElementAt(1).Id, "TestValue2" } }, 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 == message.EntryId); Assert.Equal(2, values.Count()); Assert.Contains(values, v => v.Value == "TestValue1"); Assert.Contains(values, v => v.Value == "TestValue2"); }
public async Task Handle_ConfigurationEntryDeletedEvent_UpdatesProjectVersionTracking() { // arrange var initialProject = this.CreateProject(); var initialEntity = initialProject.Entities.First(); var initialEntry = initialEntity.Entries.First(); var message = new ConfigurationEntryDeleted { Id = initialProject.Id, EntryId = initialEntry.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); }
public async Task Handle_ConfigurationEntryAddedEvent_CreatesValues() { // arrange var initialProject = this.CreateProject(); var initialEntity = initialProject.Entities.First(); var initialProperty = initialEntity.Properties.First(); var message = new ConfigurationEntryAdded { Id = initialProject.Id, EntryId = Guid.NewGuid(), EntityId = initialEntity.Id, Values = new Dictionary <Guid, object> { { initialProperty.Id, "TestValue" } }, Version = 2, TimeStamp = DateTimeOffset.Now }; var target = new ReadModelEventHandler(this.context.DbContext, this.context.Mapper); // act await target.Handle(message); // assert var value = this.context.DbContext.Values.FirstOrDefault(p => p.EntryId == message.EntryId); Assert.NotNull(value); Assert.Equal(initialProperty.Id, value.PropertyId); Assert.Equal("TestValue", value.Value); }
public async Task Handle_ConfigurationEntryModifiedEvent_UpdatesProjectVersionTracking() { // arrange var initialProject = this.CreateProject(); var initialEntity = initialProject.Entities.First(); var initialEntry = initialEntity.Entries.First(); var message = new ConfigurationEntryModified { Id = initialProject.Id, EntryId = initialEntry.Id, Values = new Dictionary <Guid, object> { { initialEntity.Properties.ElementAt(0).Id, "TestValue1" }, { initialEntity.Properties.ElementAt(1).Id, "TestValue2" } }, 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); }
public async Task Handle_PropertyDefinitionModifiedEvent_UpdatesProperty() { // arrange var initialProject = this.CreateProject(); var initialProperty = initialProject.Entities.First().Properties.First(); var message = new PropertyDefinitionModified { Id = initialProject.Id, PropertyId = initialProperty.Id, Name = "New property name", Description = "New property description", PropertyType = "Zuehlke.Eacm.String", Version = 2, TimeStamp = DateTimeOffset.Now }; var target = new ReadModelEventHandler(this.context.DbContext, this.context.Mapper); // act await target.Handle(message); // assert var property = this.context.DbContext.Properties.FirstOrDefault(p => p.Id == message.PropertyId); Assert.NotNull(property); Assert.Equal(message.Name, property.Name); Assert.Equal(message.Description, property.Description); Assert.Equal(message.PropertyType, property.PropertyType); }
public async Task Handle_ProjectModifiedEvent_UpdatesProject() { // arrange var initialProject = this.CreateProject(); var message = new ProjectModified { Id = initialProject.Id, Version = 2, TimeStamp = DateTimeOffset.Now, Name = "New Project name", Description = "New Project description" }; var target = new ReadModelEventHandler(this.context.DbContext, this.context.Mapper); // act await target.Handle(message); // assert var project = this.context.DbContext.Projects.FirstOrDefault(p => p.Id == message.Id); Assert.NotNull(project); Assert.Equal(message.Version, project.Version); Assert.Equal(message.TimeStamp, project.TimeStamp); Assert.Equal(message.Name, project.Name); Assert.Equal(message.Description, project.Description); }
public async Task Handle_PropertyDefinitionAddedEvent_AddsValueToEntry() { // arrange var initialProject = this.CreateProject(); var initialEntity = initialProject.Entities.First(); var initialEntry = initialEntity.Entries.First(); var message = new PropertyDefinitionAdded { Id = initialProject.Id, ParentEntityId = initialEntity.Id, PropertyId = Guid.NewGuid(), Name = "New property name", Description = "New property description", 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.Equal(3, values.Count()); var propertyValue = values.FirstOrDefault(v => v.PropertyId == message.PropertyId); Assert.NotNull(propertyValue); Assert.Equal(propertyValue.Value, null); }
public async Task Handle_ProjectCreatedEvent_CreatesProject() { // arrange var message = new ProjectCreated { Id = Guid.NewGuid(), Version = 1, TimeStamp = DateTimeOffset.Now, Name = "New Project", Description = "A new Project Scription" }; var target = new ReadModelEventHandler(this.context.DbContext, this.context.Mapper); // act await target.Handle(message); // assert var project = this.context.DbContext.Projects.FirstOrDefault(p => p.Id == message.Id); Assert.NotNull(project); Assert.Equal(message.Version, project.Version); Assert.Equal(message.TimeStamp, project.TimeStamp); Assert.Equal(message.Name, project.Name); Assert.Equal(message.Description, project.Description); Assert.Null(project.Description); }
public async Task Handle_EntityDefinitionModifiedEvent_UpdatesEntity() { // arrange var initialProject = this.CreateProject(); var initialEntity = initialProject.Entities.First(); var message = new EntityDefinitionModified { Id = initialProject.Id, EntityId = initialEntity.Id, Version = 2, TimeStamp = DateTimeOffset.Now, Name = "New Entity Name", Description = "new Entity Description" }; 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.NotNull(entity); Assert.Equal(message.EntityId, entity.Id); Assert.Equal(message.Id, entity.ProjectId); Assert.Equal(message.Name, entity.Name); Assert.Equal(message.Description, entity.Description); }
public async Task Handle_PropertyDefinitionDeletedEvent_DeletesProperty() { // arrange var initialProject = this.CreateProject(); var initialProperty = initialProject.Entities.First().Properties.First(); var message = new PropertyDefinitionDeleted { Id = initialProject.Id, PropertyId = initialProperty.Id, Version = 2, TimeStamp = DateTimeOffset.Now }; var target = new ReadModelEventHandler(this.context.DbContext, this.context.Mapper); // act await target.Handle(message); // assert var property = this.context.DbContext.Properties.FirstOrDefault(p => p.Id == message.PropertyId); Assert.Null(property); }
public async Task Handle_EntityDefinitionDeletedEvent_RemovesEntriesOfEntity() { // 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 entries = this.context.DbContext.Entries.Where(p => p.EntityId == message.EntityId); Assert.Empty(entries); }