示例#1
0
        public void Test_CanMatch(string token, string key, StringComparison comparisonMode, bool expectedResult)
        {
            Mock <ICacheClient> cacheClientMocker =
                new Mock <ICacheClient>(MockBehavior.Loose);

            ICacheClient cacheClient = cacheClientMocker.Object;

            KeyStartsWithStringCacheClientRule rule =
                new KeyStartsWithStringCacheClientRule(cacheClient, comparisonMode, token);

            Assert.AreEqual(expectedResult, rule.Matches(key));
            Assert.AreSame(cacheClient, rule.Client);
        }
示例#2
0
        public void Test_CanMatch_MultipleTokens(string testKey, StringComparison comparisonMode, bool expectedMatch)
        {
            Mock <ICacheClient> cacheClientMocker =
                new Mock <ICacheClient>(MockBehavior.Loose);

            ICacheClient cacheClient = cacheClientMocker.Object;

            KeyStartsWithStringCacheClientRule rule = new KeyStartsWithStringCacheClientRule(cacheClient,
                                                                                             comparisonMode,
                                                                                             "urn:iauthsession:",
                                                                                             "sess:");

            Assert.AreEqual(expectedMatch, rule.Matches(testKey));
        }
示例#3
0
        private IRoutedCacheClient CreateRoutedCacheClient(ICacheClient fallbackClient, ICacheClient sessionClient, params IRoutedCacheClientRule[] rules)
        {
            IRoutedCacheClientRule sessionCacheClientRule = new KeyStartsWithStringCacheClientRule(sessionClient,
                                                                                                   StringComparison.InvariantCultureIgnoreCase,
                                                                                                   SessionKeyPrefix);

            IRoutedCacheClientRule[] newRules = new IRoutedCacheClientRule[rules.Length + 1];

            newRules[0] = sessionCacheClientRule;
            for (int i = 0; i < rules.Length; i++)
            {
                newRules[i + 1] = rules[i];
            }

            return(CreateRoutedCacheClient(fallbackClient,
                                           newRules));
        }