Пример #1
0
        public async Task When_FilterCalled_Then_RemoveAllCachedPattern_Test(string method, string path, string patternRemove)
        {
            Configuration
            .SetupGet(d => d.CurrentValue)
            .Returns(GetConfiguration(new Dictionary <string, string>()
            {
                { path, patternRemove }
            }));

            CachedRemoveByConfigurationAttribute = new CachedRemoveByConfigurationAttribute(
                ResponseCacheServiceMock.Object,
                Configuration.Object
                );

            var expectedValue = new { prop1 = "teste" };

            ActionExecutionDelegateMock
            .Setup(d => d.Invoke())
            .ReturnsAsync(
                SetActionExecutedContext(expectedValue)
                );

            HttpContext.Request.Method = method;
            HttpContext.Request.Path   = path;

            //Act
            await CachedRemoveByConfigurationAttribute.OnActionExecutionAsync(Context, ActionExecutionDelegateMock.Object);

            ResponseCacheServiceMock.Verify_GetKeysByPattern(Times.Once(), patternRemove);
            ResponseCacheServiceMock.Set_RemoveCachedResponseByNameAsync(Times.Once());
        }