Browse Source

Test for route attribute.

pull/680/head
Sebastian Stehle 5 years ago
parent
commit
7d7833919f
  1. 40
      backend/tests/Squidex.Web.Tests/UrlDecodeRouteParamsAttributeTests.cs

40
backend/tests/Squidex.Web.Tests/UrlDecodeRouteParamsAttributeTests.cs

@ -0,0 +1,40 @@
// ==========================================================================
// Squidex Headless CMS
// ==========================================================================
// Copyright (c) Squidex UG (haftungsbeschraenkt)
// All rights reserved. Licensed under the MIT license.
// ==========================================================================
using System.Collections.Generic;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Abstractions;
using Microsoft.AspNetCore.Mvc.Filters;
using Microsoft.AspNetCore.Routing;
using Xunit;
namespace Squidex.Web
{
public class UrlDecodeRouteParamsAttributeTests
{
[Fact]
public void Should_url_decode_params()
{
var sut = new UrlDecodeRouteParamsAttribute();
var actionContext = new ActionContext(new DefaultHttpContext(), new RouteData(), new ActionDescriptor
{
FilterDescriptors = new List<FilterDescriptor>()
});
var actionExecutingContext = new ActionExecutingContext(actionContext, new List<IFilterMetadata>(), new Dictionary<string, object>
{
["key"] = "path%2Fto%2Fsomething"
}, null!);
sut.OnActionExecuting(actionExecutingContext);
Assert.Equal("path/to/something", actionExecutingContext.ActionArguments["key"]);
}
}
}
Loading…
Cancel
Save