public void FireEvent(OracleNotificationType notificationType, OracleNotificationInfo notificationInfo) { var notificationArgsFake = A.Fake <ISignalRDbNotificationEventArgs>(); A.CallTo(() => notificationArgsFake.NotificationType).Returns((int)notificationType); A.CallTo(() => notificationArgsFake.NotificationInfo).Returns((int)notificationInfo); if (OnChanged != null) { OnChanged(this, notificationArgsFake); } }
void dependency_OnChange(object sender, OracleNotificationEventArgs eventArgs) { try { if (Observers.Count != 0) { if (Notifications != null) { foreach (System.Data.DataRow detailsRow in eventArgs.Details.Rows) { string rowId = detailsRow["rowid"].ToString(); if (string.IsNullOrEmpty(rowId)) { UpdateNotifications(); break; } else { string resourceName = detailsRow["resourcename"].ToString().ToLower(); OracleNotificationInfo oracleNotificationInfo = (OracleNotificationInfo)detailsRow["info"]; NotificationType notificationType = NotificationType.None; if ((oracleNotificationInfo & OracleNotificationInfo.Insert) == OracleNotificationInfo.Insert) { notificationType = NotificationType.Insert; } else if ((oracleNotificationInfo & OracleNotificationInfo.Update) == OracleNotificationInfo.Update) { notificationType = NotificationType.Update; } else if ((oracleNotificationInfo & OracleNotificationInfo.Delete) == OracleNotificationInfo.Delete) { notificationType = NotificationType.Delete; } else { notificationType = NotificationType.Table; } if (notificationType != NotificationType.None) { if (Query.NotificationLevel == NotificationLevel.Row || Query.NotificationMechanism == NotificationMechanism.Poll) { Key surrogateKey = new Key(rowId); Key key; if (notificationType == NotificationType.Delete) { key = _dataIndex[surrogateKey].Key; _dataIndex.Remove(surrogateKey); } else { UpdateDataIndex(surrogateKey, notificationType); key = _dataIndex[surrogateKey].Key; } Notifications.Add(new Notification(notificationType, Query.Name, Query.KeyFieldNames, key.Values)); } else { Notifications.Add(new Notification(notificationType, Query.Name, null, null)); } } } } RaiseNotifications(); } } } catch (Exception ex) { if (_log.IsErrorEnabled) { _log.ErrorFormat("Failed to process database notification for query '{0}' - {1}", Query.Name, ex.Message); } } }