public void ShouldHaveDeletedEvent() { // Arrange Guid expectedId = Guid.NewGuid(); Role actual = Role.Create(expectedId, "Name", "Code"); actual.FlushUncommitedEvents(); // Act actual.Delete(); // Assert Assert.IsTrue(actual.Events != null); Assert.IsTrue(actual.Events.Count == 1); var events = actual.FlushUncommitedEvents(); Assert.IsTrue(events != null); Assert.IsTrue(events.Length == 1); Assert.IsTrue(events[0] is RoleDeletedEvent); RoleDeletedEvent @event = events[0] as RoleDeletedEvent; Assert.IsTrue(@event.EntityId == expectedId); }
public Task ExecuteAsync(HookType type, IDomainEntityContext <Role> context, CancellationToken cancellationToken) { switch (context.EditMode) { case EditMode.Create: context.AddEventAsync(RoleCreatedEvent.Create(_correlationIdProvider.Id, context.Entity.Id, _currentUser.Id), cancellationToken); break; case EditMode.Update: context.AddEventAsync(RoleUpdatedEvent.Create(_correlationIdProvider.Id, context.Entity.Id, _currentUser.Id), cancellationToken); break; case EditMode.Delete: context.AddEventAsync(RoleDeletedEvent.Create(_correlationIdProvider.Id, context.Entity.Id, _currentUser.Id), cancellationToken); break; } return(Task.CompletedTask); }