Ejemplo n.º 1
0
        public void SaveTempDataFilter_OnResourceExecuted_SavesTempData()
        {
            // Arrange
            var tempData = new Mock<ITempDataDictionary>(MockBehavior.Strict);
            tempData
                .Setup(m => m.Save())
                .Verifiable();

            var tempDataFactory = new Mock<ITempDataDictionaryFactory>(MockBehavior.Strict);
            tempDataFactory
                .Setup(f => f.GetTempData(It.IsAny<HttpContext>()))
                .Returns(tempData.Object);

            var filter = new SaveTempDataFilter(tempDataFactory.Object);

            var context = new ResourceExecutedContext(
                new ActionContext(new DefaultHttpContext(), new RouteData(), new ActionDescriptor()),
                new IFilterMetadata[] { });

            // Act
            filter.OnResourceExecuted(context);

            // Assert
            tempData.Verify();
        }
Ejemplo n.º 2
0
 public void OnResourceExecuted(ResourceExecutedContext context)
 {
     context.HttpContext.Response.Headers.Append(
         "filters", 
         Name + " - OnResourceExecuted");
 }
Ejemplo n.º 3
0
 public void OnResourceExecuted(ResourceExecutedContext context)
 {
     _logger.LogInformation("OnResourceExecuted");
 }
Ejemplo n.º 4
0
 /// <inheritdoc />
 public void OnResourceExecuted(ResourceExecutedContext context)
 {
 }
Ejemplo n.º 5
0
 /// <inheritdoc />
 public void OnResourceExecuted(ResourceExecutedContext context)
 {
     _factory.GetTempData(context.HttpContext).Save();
 }
Ejemplo n.º 6
0
 /// <inheritdoc />
 public void OnResourceExecuted(ResourceExecutedContext context)
 {
     _tempData.Save();
 }
 public static void AfterOnResourceExecuted(
     this DiagnosticSource diagnosticSource,
     ActionDescriptor actionDescriptor,
     ResourceExecutedContext resourceExecutedContext,
     IResourceFilter filter)
 {
     if (diagnosticSource.IsEnabled("Microsoft.AspNet.Mvc.AfterOnResourceExecuted"))
     {
         diagnosticSource.Write(
             "Microsoft.AspNet.Mvc.AfterOnResourceExecuted",
             new
             {
                 actionDescriptor = actionDescriptor,
                 resourceExecutedContext = resourceExecutedContext,
                 filter = filter
             });
     }
 }