private static ISet <BackplaneMessage> CreateMany(byte[] owner)
        {
            var messages = new HashSet <BackplaneMessage>();
            var key      = Guid.NewGuid().ToString();
            var region   = Guid.NewGuid().ToString();

            // test hash compare works too, result hashset should still have 41 messages only!
            for (var m = 0; m < 10000; m++)
            {
                for (var i = 0; i < 10; i++)
                {
                    messages.Add(BackplaneMessage.ForChanged(owner, key + i, CacheItemChangedEventAction.Update));
                    messages.Add(BackplaneMessage.ForChanged(owner, key + i, region, CacheItemChangedEventAction.Add));
                }

                messages.Add(BackplaneMessage.ForClear(owner));

                for (var i = 0; i < 10; i++)
                {
                    messages.Add(BackplaneMessage.ForClearRegion(owner, region + i));
                }
                for (var i = 0; i < 10; i++)
                {
                    messages.Add(BackplaneMessage.ForRemoved(owner, key + i, region));
                }
            }

            return(messages);
        }
        public void BackplaneMessage_NotEqualOther()
        {
            // arrange
            var owner = new byte[] { 1, 2, 3, 4 };

            var region = Guid.NewGuid().ToString();
            var msg    = BackplaneMessage.ForClearRegion(owner, region);

            // act
            msg.Equals("hello").Should().BeFalse();
        }
        public void BackplaneMessage_RefEquals()
        {
            // arrange
            var owner = new byte[] { 1, 2, 3, 4 };

            var region = Guid.NewGuid().ToString();
            var msg    = BackplaneMessage.ForClearRegion(owner, region);

            // act
            msg.Equals(msg).Should().BeTrue();
        }
        public void BackplaneMessage_HashClearRegion()
        {
            // arrange
            var owner = new byte[] { 1, 2, 3, 4 };

            var region = Guid.NewGuid().ToString();
            var msg    = BackplaneMessage.ForClearRegion(owner, region);
            var msg2   = BackplaneMessage.ForClearRegion(owner, region);

            // act
            msg.GetHashCode().Should().Be(msg2.GetHashCode());
        }
        public void BackplaneMessage_ClearRegion()
        {
            // arrange
            var owner = new byte[] { 1, 2, 3, 4 };

            var region = Guid.NewGuid().ToString();
            var msg    = BackplaneMessage.ForClearRegion(owner, region);

            // act
            var serialized   = BackplaneMessage.Serialize(msg);
            var deserialized = BackplaneMessage.Deserialize(serialized).First();

            // assert
            deserialized.Key.Should().Be(null);
            deserialized.Region.Should().Be(region);
            deserialized.ChangeAction.Should().Be(CacheItemChangedEventAction.Invalid);
            deserialized.Action.Should().Be(BackplaneAction.ClearRegion);
            deserialized.OwnerIdentity.ShouldBeEquivalentTo(owner);
            deserialized.ShouldBeEquivalentTo(msg);
        }
Beispiel #6
0
        static BackplaneMessageBenchmarkMultiple()
        {
            var messages = new List <BackplaneMessage>();

            for (var i = 0; i < 10; i++)
            {
                messages.Add(BackplaneMessage.ForChanged(_ownderBytes, "somerandomkey" + i, CacheItemChangedEventAction.Update));
                messages.Add(BackplaneMessage.ForChanged(_ownderBytes, "somerandomkey" + i, "withregion", CacheItemChangedEventAction.Add));
            }
            for (var i = 0; i < 10; i++)
            {
                messages.Add(BackplaneMessage.ForClear(_ownderBytes));
            }
            for (var i = 0; i < 10; i++)
            {
                messages.Add(BackplaneMessage.ForClearRegion(_ownderBytes, "somerandomregion" + i));
            }
            for (var i = 0; i < 10; i++)
            {
                messages.Add(BackplaneMessage.ForRemoved(_ownderBytes, "somerandomkey" + i, "withregion"));
            }
            _multiple = messages.ToArray();
        }
Beispiel #7
0
 /// <summary>
 /// Notifies other cache clients about a cache clear region call.
 /// </summary>
 /// <param name="region">The region.</param>
 public override void NotifyClearRegion(string region)
 {
     this.PublishMessage(BackplaneMessage.ForClearRegion(this.identifier, region));
 }
Beispiel #8
0
 /// <summary>
 /// Notifies other cache clients about a cache clear region call.
 /// </summary>
 /// <param name="region">The region.</param>
 public override Task NotifyClearRegionAsync(string region)
 {
     return(PublishMessageAsync(BackplaneMessage.ForClearRegion(_identifier, region)));
 }