public MockReliableStateManager()
        {
            // Initialze _store to a TransactedConcurrentDictionary that fires the StateManagerChanged event in the OnDictionaryChanged callback.
            _store = new TransactedConcurrentDictionary <Uri, IReliableState>(
                new Uri("fabric://state", UriKind.Absolute),
                (c) =>
            {
                if (StateManagerChanged != null)
                {
                    NotifyStateManagerSingleEntityChangedEventArgs changeEvent;
                    switch (c.ChangeType)
                    {
                    case ChangeType.Added:
                        changeEvent = new NotifyStateManagerSingleEntityChangedEventArgs(c.Transaction, c.Added, NotifyStateManagerChangedAction.Add);
                        break;

                    case ChangeType.Removed:
                        changeEvent = new NotifyStateManagerSingleEntityChangedEventArgs(c.Transaction, c.Removed, NotifyStateManagerChangedAction.Remove);
                        break;

                    default:
                        return(false);
                    }

                    StateManagerChanged.Invoke(this, changeEvent);
                }

                return(true);
            }
                );
        }
        public MockReliableStateManager(TransactedConcurrentDictionary <Uri, IReliableState> store = null)
        {
            _store = store ?? new TransactedConcurrentDictionary <Uri, IReliableState>(new Uri("fabric://state", UriKind.Absolute));
            _store.InternalDictionaryChanged +=
                (sender, args) =>
            {
                if (StateManagerChanged != null)
                {
                    NotifyStateManagerSingleEntityChangedEventArgs changeEvent = null;
                    switch (args.ChangeType)
                    {
                    case ChangeType.Added:
                        changeEvent = new NotifyStateManagerSingleEntityChangedEventArgs(args.Transaction, args.Added, NotifyStateManagerChangedAction.Add);
                        break;

                    case ChangeType.Removed:
                        changeEvent = new NotifyStateManagerSingleEntityChangedEventArgs(args.Transaction, args.Removed, NotifyStateManagerChangedAction.Remove);
                        break;
                    }

                    StateManagerChanged.Invoke(this, changeEvent);
                }
            };
        }
 public void OnStateManagerChanged(NotifyStateManagerChangedEventArgs e)
 {
     StateManagerChanged?.Invoke(this, e);
 }