コード例 #1
0
        public void return_true_when_2_sentinel_key_arent_equals()
        {
            var sentinelKey1 = new SentinelKey("sentinel1");
            var sentinelKey2 = new SentinelKey("sentinel2");

            Check.That(sentinelKey1 != sentinelKey2).IsEqualTo(true);
        }
コード例 #2
0
        public SubscriptionKey AddSubscription(SentinelKey clientSentinelKey, string stateValueSentinelName, string stateValuePackageName, string stateValueName)
        {
            var stateValueKey = _stateValueManager.GetStateValueKey(stateValueSentinelName, stateValuePackageName, stateValueName);

            var subscriptionOnStateValue = SubscriptionOnStateValue.CreateSubscriptionOnStateValue(
                _stateValueManager.GetStateValueKey(stateValueSentinelName, stateValuePackageName, stateValueName));

            if (_subscriptions.ContainsKey(clientSentinelKey))
            {
                var stateValueKeys = _subscriptions[clientSentinelKey].Where(v => v.StateValueKey == stateValueKey);
                if (stateValueKeys.Any())
                {
                    stateValueKeys.First().Id = subscriptionOnStateValue.Id;
                }
                else
                {
                    _subscriptions[clientSentinelKey].Add(subscriptionOnStateValue);
                }
            }
            else
            {
                _subscriptions.Add(clientSentinelKey, new List <SubscriptionOnStateValue> {
                    subscriptionOnStateValue
                });
            }

            SubscribeOnValueChangedEventIfStateValueExist(stateValueKey);
            return(subscriptionOnStateValue.Id);
        }
コード例 #3
0
        public void return_true_when_2_sentinel_key_are_equals_with_override_equals_method()
        {
            var sentinelKey1 = new SentinelKey("sentinel1");
            var sentinelKey2 = new SentinelKey("sentinel1");

            Check.That(sentinelKey1.Equals(sentinelKey2)).IsEqualTo(true);
        }
コード例 #4
0
 private void RemoveSubscriptionSentinelKeyEntryIfEmpty(SentinelKey sentinelKey)
 {
     if (!_subscriptions[sentinelKey].Any())
     {
         _subscriptions.Remove(sentinelKey);
     }
 }
コード例 #5
0
ファイル: Subscription.cs プロジェクト: NestorHub/Common
 public Subscription(string sentinelKey, string stateValueSentinelName, string stateValuePackageName, string stateValueName)
 {
     SentinelKey            = new SentinelKey(sentinelKey);
     StateValueSentinelName = stateValueSentinelName;
     StateValuePackageName  = stateValuePackageName;
     StateValueName         = stateValueName;
 }
コード例 #6
0
        public bool RemoveSubscription(SentinelKey sentinelKey, SubscriptionKey subscriptionId)
        {
            if (_subscriptions.Any(s => s.Key == sentinelKey))
            {
                _subscriptions[sentinelKey].RemoveAll(s => s.Id == subscriptionId);

                RemoveSubscriptionSentinelKeyEntryIfEmpty(sentinelKey);
                return(true);
            }
            else
            {
                throw new NoSubscriptionFoundException();
            }
        }
コード例 #7
0
        public void return_true_when_second_sentinel_key_is_null_on_different()
        {
            var sentinelKey = new SentinelKey("sentinel1");

            Check.That(null != sentinelKey).IsTrue();
        }
コード例 #8
0
        public void return_false_when_second_sentinel_key_is_null_on_equal()
        {
            var sentinelKey = new SentinelKey("sentinel1");

            Check.That(null == sentinelKey).IsFalse();
        }
コード例 #9
0
 public SentinelSubscriptions(SentinelKey sentinelKey)
 {
     SentinelKey    = sentinelKey;
     StateValueKeys = new List <StateValueKey>();
 }
コード例 #10
0
ファイル: SubscribeManager.cs プロジェクト: NestorHub/Server
 public bool Delete(SentinelKey sentinelKey, SubscriptionKey subscriptionKey)
 {
     return(_subscriptionManager.RemoveSubscription(sentinelKey, subscriptionKey));
 }