public void TestOnCreateTenant() { bool success = true; string tenantName = "Tenant" + Guid.NewGuid(); var mockAuditLog = new Mock <IAuditLog>(MockBehavior.Strict); mockAuditLog.Setup(al => al.OnCreateTenant(success, tenantName)); var eventTarget = new AuditLogTenantEventTarget(mockAuditLog.Object); var tenant = new Tenant { Name = tenantName }; IDictionary <string, object> state = new Dictionary <string, object>(); eventTarget.GatherAuditLogEntityDetailsForSave(tenant, state); eventTarget.WriteSaveAuditLogEntries(success, tenant.Id, state); mockAuditLog.VerifyAll(); }
/// <summary> /// Called before saving the enumeration of entities. /// </summary> /// <param name="entities">The entities.</param> /// <param name="state">The state passed between the before save and after save callbacks.</param> /// <returns> /// True to cancel the save operation; false otherwise. /// </returns> public bool OnBeforeSave(IEnumerable <IEntity> entities, IDictionary <string, object> state) { var newTenants = new List <long>(); foreach (IEntity entity in entities) { var tenant = entity.As <Tenant>(); if (tenant == null) { continue; } _auditLogEventTarget.GatherAuditLogEntityDetailsForSave(tenant, state); if (tenant.IsTemporaryId) // new tenant { newTenants.Add(tenant.Id); } } state[NewTenantKey] = newTenants; return(false); }