public void Should_only_add_duplicate_items_once()
        {
            var table = new IdempotentHashtable <Uri, object>();

            table.Add(a, new object());
            table.Add(a, new object());

            Assert.AreEqual(1, table.Count);

            table.Add(b, new object());
            Assert.AreEqual(2, table.Count);
        }
Ejemplo n.º 2
0
        public void Adds()
        {
            IdempotentHashtable <Uri, object> table = new IdempotentHashtable <Uri, object>();

            table.Add(a, new object());
            table.Add(a, new object());

            Assert.AreEqual(1, table.Count);

            table.Add(b, new object());
            Assert.AreEqual(2, table.Count);
        }
		public void Should_only_add_duplicate_items_once()
		{
			var table = new IdempotentHashtable<Uri, object>();

			table.Add(a, new object());
			table.Add(a, new object());

			Assert.AreEqual(1, table.Count);

			table.Add(b, new object());
			Assert.AreEqual(2, table.Count);
		}
        public void Should_not_fail_when_removing_non_existent_items()
        {
            var table = new IdempotentHashtable <Uri, object>();

            table.Add(a, new object());
            table.Add(b, new object());

            table.Remove(a);
            table.Remove(a);
            table.Remove(a);
            table.Remove(a);

            Assert.AreEqual(1, table.Count);
        }
Ejemplo n.º 5
0
        public void Removes()
        {
            IdempotentHashtable<Uri, object> table = new IdempotentHashtable<Uri, object>();

            table.Add(a, new object());
            table.Add(b, new object());

            table.Remove(a);
            table.Remove(a);
            table.Remove(a);
            table.Remove(a);

            Assert.AreEqual(1, table.Count);
        }
		public void Should_not_fail_when_removing_non_existent_items()
		{
			var table = new IdempotentHashtable<Uri, object>();

			table.Add(a, new object());
			table.Add(b, new object());

			table.Remove(a);
			table.Remove(a);
			table.Remove(a);
			table.Remove(a);

			Assert.AreEqual(1, table.Count);
		}
Ejemplo n.º 7
0
        private UnsubscribeAction SendAddSubscription(SubscriptionInformation info)
        {
            if (_ignoredSubscriptions.Contains(info.MessageName))
            {
                return(() => true);
            }

            var add = new AddSubscription(info);

            ClientSubscriptionInformation clientInfo = _mapper.Transform(info);

            if (clientInfo.Unsubscribe == null)
            {
                clientInfo.Unsubscribe = () => true;
            }

            lock (_subscriptions)
            {
                _subscriptions.Add(clientInfo.SubscriptionId, clientInfo);
            }

            _subscriptionServiceEndpoint.Send(add);
            return(() =>
            {
                var remove = new RemoveSubscription(info, _sequence.Next());

                _subscriptionServiceEndpoint.Send(remove);

                return true;
            });
        }