Esempio n. 1
0
        private RevokeContextConcurrentCollection CreateRevokeContextConcurrentCollection(int entries = 10)
        {
            var res = new RevokeContextConcurrentCollection();

            for (var i = 0; i < entries; i++)
            {
                var rc = this.CreateRevokeContextRooted(i);
                res.Insert(rc);
            }

            return(res);
        }
Esempio n. 2
0
        public void MergeMissingEntriesWith_Collection_With_Another_Collection_Containing_Same_Entries_Should_Not_Add_Entries()
        {
            // Arrange
            var revokeContextConcurrentCollection = new RevokeContextConcurrentCollection();

            var other = new RevokeContextConcurrentCollection();
            var rc    = this.CreateRevokeContextRooted();

            revokeContextConcurrentCollection.Insert(rc);
            other.Insert(rc);

            // Act
            var result = revokeContextConcurrentCollection.MergeMissingEntriesWith(
                other);

            // Assert
            Assert.AreEqual(1, revokeContextConcurrentCollection.Count());
        }
Esempio n. 3
0
        public void GetLiveRevokeesAndSafelyRemoveDeadOnes_Existing_Key_For_Collected_Context_Should_Return_Empty_Enumerable()
        {
            // Arrange
            var rcc = new RevokeContextConcurrentCollection();
            var sub = Substitute.For <IRevokeContextConcurrentCollectionFactory>();

            sub.Create().Returns(_ => rcc);
            var revokeKeyIndexer = new RevokeKeyIndexer(
                sub,
                this.subLog);;
            string revokeKey = "existing";

            revokeKeyIndexer.AddRevokeContext(revokeKey, CreateRevokeContext());
            // Act
            var res = revokeKeyIndexer.GetLiveRevokeesAndSafelyRemoveDeadOnes(
                revokeKey);

            // Assert
            Assert.IsEmpty(res);
        }
Esempio n. 4
0
        public void GetLiveRevokeesAndSafelyRemoveDeadOnes_dead_Entries_Should_Be_Cleaned2()
        {
            // Arrange
            var rcc = new RevokeContextConcurrentCollection();
            var sub = Substitute.For <IRevokeContextConcurrentCollectionFactory>();

            sub.Create().Returns(_ => rcc);
            var revokeKeyIndexer = new RevokeKeyIndexer(
                sub,
                this.subLog);;
            string revokeKey = "existing";

            revokeKeyIndexer.AddRevokeContext(revokeKey, CreateRevokeContext());

            // Act
            var res = revokeKeyIndexer.GetLiveRevokeesAndSafelyRemoveDeadOnes(
                revokeKey);

            // Assert
            Assert.False(revokeKeyIndexer.ContainsKey(revokeKey));
        }