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)); }
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)); }
/// <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) { }
public static PageActionDescriptorDebugObject GetDebugObject(this PageActionDescriptor pageActionDescriptor) => new PageActionDescriptorDebugObject(pageActionDescriptor);
/// <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; }