public void given_new_permission_should_be_disabled_after_permission_disabled_event() { //assemble CreateNewPermissionDTO input = new CreateNewPermissionDTO { Name = "test", Description = "test", IsActive = true }; var agg = PermissionAggregate.CreateNewPermission(input); var adminUser = PermissionAggregateMockAggregate.SetupAdminUser(); //apply agg.DisablePermission(adminUser); //assert var changes = agg.GetUncommittedChanges(); Assert.Equal(2, changes.Length); Assert.Collection(changes, (e) => { Assert.IsType <PermissionCreatedEvent>(e); }, (e) => { Assert.IsType <PermissionDisabledEvent>(e); var @event = (PermissionDisabledEvent)e; Assert.False(@event.IsActive); }); Assert.False(agg.IsActive); }
public void given_new_permission_should_have_correct_values_after_update_permission_event() { //assemble CreateNewPermissionDTO input = new CreateNewPermissionDTO { Name = "test", Description = "test", IsActive = true }; var agg = PermissionAggregate.CreateNewPermission(input); var userAgg = PermissionAggregateMockAggregate.SetupAdminUser(); var updateInfo = new UpdatePermissionInfoDTO { Id = agg.Id, UpdatedById = userAgg.Id, Name = "New Name", Description = "New Description", }; //apply agg.UpdatePermissionInfo(updateInfo); //assert var changes = agg.GetUncommittedChanges(); Assert.Equal(2, changes.Length); Assert.Collection(changes, (e) => { Assert.IsType <PermissionCreatedEvent>(e); }, (e) => { Assert.IsType <PermissionInfoUpdatedEvent>(e); var @event = (PermissionInfoUpdatedEvent)e; Assert.Equal(@event.Name, updateInfo.Name); Assert.Equal(@event.Description, updateInfo.Description); }); Assert.Equal(agg.Name, updateInfo.Name); Assert.Equal(agg.Description, updateInfo.Description); }