コード例 #1
0
        public void Remove_Object_Should_Remove_From_All_Keys()
        {
            // Arrange
            var sub = Substitute.For <IRevokeContextConcurrentCollectionFactory>();

            sub.Create().Returns(_ => new RevokeContextConcurrentCollection());
            var revokeKeyIndexer = new RevokeKeyIndexer(
                sub,
                this.subLog);;
            var    context = CreateRevokeContextRooted();
            object obj     = context.Revokee;
            string key1    = "key1";
            string key2    = "key2";

            revokeKeyIndexer.AddRevokeContext(key1, context);
            revokeKeyIndexer.AddRevokeContext(key2, context);

            // Act
            revokeKeyIndexer.Remove(obj);

            //Assert
            Assert.IsEmpty(revokeKeyIndexer.GetLiveRevokeesAndSafelyRemoveDeadOnes(key1));
            Assert.IsEmpty(revokeKeyIndexer.GetLiveRevokeesAndSafelyRemoveDeadOnes(key2));
        }
コード例 #2
0
        public void Remove_Existing_Key_Should_Succeed()
        {
            // Arrange
            var sub = Substitute.For <IRevokeContextConcurrentCollectionFactory>();

            sub.Create().Returns(_ => new RevokeContextConcurrentCollection());
            var revokeKeyIndexer = new RevokeKeyIndexer(
                sub,
                this.subLog);;
            var    context = CreateRevokeContextRooted();
            object obj     = context.Revokee;
            string key     = "key";

            revokeKeyIndexer.AddRevokeContext(key, context);

            // Act
            var res = revokeKeyIndexer.Remove(
                obj,
                key);

            //Assert
            Assert.True(res);
            Assert.False(revokeKeyIndexer.ContainsKey(key));
        }