示例#1
0
        public void GetKey_FunctionWithoutParameters_ShouldReturnCacheKeyString()
        {
            using var fixture = new ExpressionCacheBaseFixture();
            var key      = fixture.ExpressionCacheBase.GetKey(() => _testFunctions.FunctionWithoutParameters());
            var asyncKey = fixture.ExpressionCacheBase.GetKey(() => _testFunctions.FunctionWithoutParametersAsync());

            key.Should().Be(CacheKeyHelper.Prefix(
                                CacheKeyHelper.Format(_testFunctions.ClassName) +
                                CacheKeyHelper.Format(nameof(_testFunctions.FunctionWithoutParameters))));
            asyncKey.Should().Be(CacheKeyHelper.Prefix(
                                     CacheKeyHelper.Format(_testFunctions.ClassName) +
                                     CacheKeyHelper.Format(nameof(_testFunctions.FunctionWithoutParametersAsync))));
        }
示例#2
0
        public void GetKey_FunctionWithTwoParameters_ShouldReturnCacheKeyString()
        {
            const int    parameterOne = 1;
            const string parameterTwo = "Testing";

            using var fixture = new ExpressionCacheBaseFixture();
            var key      = fixture.ExpressionCacheBase.GetKey(() => _testFunctions.FunctionWithTwoParameters(parameterOne, parameterTwo));
            var asyncKey = fixture.ExpressionCacheBase.GetKey(() => _testFunctions.FunctionWithTwoParametersAsync(parameterOne, parameterTwo));

            key.Should().Be(CacheKeyHelper.Prefix(
                                CacheKeyHelper.Format(_testFunctions.ClassName) +
                                CacheKeyHelper.Format(nameof(_testFunctions.FunctionWithTwoParameters)) +
                                CacheKeyHelper.Format(parameterOne) +
                                CacheKeyHelper.Format(parameterTwo)));
            asyncKey.Should().Be(CacheKeyHelper.Prefix(
                                     CacheKeyHelper.Format(_testFunctions.ClassName) +
                                     CacheKeyHelper.Format(nameof(_testFunctions.FunctionWithTwoParametersAsync)) +
                                     CacheKeyHelper.Format(parameterOne) +
                                     CacheKeyHelper.Format(parameterTwo)));
        }