예제 #1
0
        public void OnProvidersExecuting_AddsFiltersToModel()
        {
            // Arrange
            var actionDescriptor = new PageActionDescriptor();
            var applicationModel = new PageApplicationModel(
                actionDescriptor,
                typeof(object).GetTypeInfo(),
                new object[0]);
            var applicationModelProvider = new AutoValidateAntiforgeryPageApplicationModelProvider();
            var context = new PageApplicationModelProviderContext(new PageActionDescriptor(), typeof(object).GetTypeInfo())
            {
                PageApplicationModel = applicationModel,
            };

            // Act
            applicationModelProvider.OnProvidersExecuting(context);

            // Assert
            Assert.Collection(
                applicationModel.Filters,
                filter => Assert.IsType <AutoValidateAntiforgeryTokenAttribute>(filter));
        }
예제 #2
0
        public void OnProvidersExecuting_DoesNotAddAutoValidateAntiforgeryTokenAttribute_IfAntiforgeryPolicyExists()
        {
            // Arrange
            var expected = Mock.Of <IAntiforgeryPolicy>();

            var descriptor = new PageActionDescriptor();
            var provider   = new AutoValidateAntiforgeryPageApplicationModelProvider();
            var context    = new PageApplicationModelProviderContext(descriptor, typeof(object).GetTypeInfo())
            {
                PageApplicationModel = new PageApplicationModel(descriptor, typeof(object).GetTypeInfo(), Array.Empty <object>())
                {
                    Filters = { expected },
                },
            };

            // Act
            provider.OnProvidersExecuting(context);

            // Assert
            Assert.Collection(
                context.PageApplicationModel.Filters,
                actual => Assert.Same(expected, actual));
        }
예제 #3
0
 /// <summary>
 /// Initializes a new instance of <see cref="CompiledPageActionDescriptor"/>
 /// from the specified <paramref name="actionDescriptor"/> instance.
 /// </summary>
 /// <param name="actionDescriptor">The <see cref="PageActionDescriptor"/>.</param>
 public CompiledPageActionDescriptor(PageActionDescriptor actionDescriptor)
     : base(actionDescriptor)
 {
 }
예제 #4
0
 public static PageActionDescriptorDebugObject GetDebugObject(this PageActionDescriptor pageActionDescriptor) => new PageActionDescriptorDebugObject(pageActionDescriptor);
예제 #5
0
 /// <summary>
 /// A copy constructor for <see cref="PageActionDescriptor"/>.
 /// </summary>
 /// <param name="other">The <see cref="PageActionDescriptor"/> to copy from.</param>
 public PageActionDescriptor(PageActionDescriptor other)
 {
     RelativePath   = other.RelativePath;
     ViewEnginePath = other.ViewEnginePath;
 }