/// <summary> /// Called after saving of the specified enumeration of entities has taken place. /// </summary> /// <param name="entities">The entities.</param> /// <param name="state">The state passed between the before save and after save callbacks.</param> public void OnAfterSave(IEnumerable <IEntity> entities, IDictionary <string, object> state) { foreach (long entityId in entities.Select(e => e.Id)) { _auditLogEventTarget.WriteSaveAuditLogEntries(true, entityId, state); } }
public void TestOnChangeAccessRuleQuery() { bool success = true; string subjectName = "Role" + Guid.NewGuid(); string typeName = "Type" + Guid.NewGuid(); string reportName = "Report" + Guid.NewGuid(); string newReportName = "Report" + Guid.NewGuid(); var mockAuditLog = new Mock <IAuditLog>(MockBehavior.Strict); mockAuditLog.Setup(al => al.OnChangeAccessRuleQuery(success, subjectName, typeName, newReportName)); var eventTarget = new AuditLogReportEventTarget(mockAuditLog.Object); var subject = new Role { Name = subjectName }; var type = new EntityType { Name = typeName }; var report = new Report { Name = reportName }; var accessRule = new AccessRule { AllowAccessBy = subject.As <Subject>(), ControlAccess = type.As <SecurableEntity>(), AccessRuleReport = report }; accessRule.Save(); report.Name = newReportName; IDictionary <string, object> state = new Dictionary <string, object>(); eventTarget.GatherAuditLogEntityDetailsForSave(report, state); eventTarget.WriteSaveAuditLogEntries(success, report.Id, state); mockAuditLog.VerifyAll(); }