Example #1
0
        /// <summary>
        ///     Called if a failure occurs saving the specified entities.
        /// </summary>
        /// <param name="entities">The entities.</param>
        /// <param name="state">The state passed between the before save and after save callbacks.</param>
        public void OnSaveFailed(IEnumerable <IEntity> entities, IDictionary <string, object> state)
        {
            if (entities == null)
            {
                return;
            }

            foreach (long entity in entities.Select(e => e.Id))
            {
                _auditLogEventTarget.WriteSaveAuditLogEntries(false, entity, state);
            }
        }
Example #2
0
        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();
        }