Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1.3.0 breaks tests #289

Open
aueelis opened this issue Mar 13, 2020 · 1 comment
Open

1.3.0 breaks tests #289

aueelis opened this issue Mar 13, 2020 · 1 comment

Comments

@aueelis
Copy link

aueelis commented Mar 13, 2020

We are trying to upgrade an existing project from 1.2.6 to 1.3.0 and are having problems with suddenly breaking tests.

What's the problem with the following test that works in 1.2.6 but not in 1.3.0?

using System.Net.Http;
using System.Threading.Tasks;
using System.Web.Http;
using MyTested.WebApi;
using NUnit.Framework;

namespace TestApi.Tests.Controllers
{
    public class ValuesController : ApiController
    {
        [HttpPost]
        [Route("api/value")]
        public async Task<int> GetValue(TestRequest request)
        {
            return await (Task.FromResult(request.Value));
        }
    }

    public class TestRequest
    {
        public int Value { get; set; }
    }

    [TestFixture]
    public class ValuesControllerTest
    {
        [Test]
        public void Has_Correct_Route()
        {
            MyWebApi.Routes()
                .ShouldMap("api/value")
                .WithHttpMethod(HttpMethod.Post)
                .WithJsonContent("{ value: 1 }")
                .To<ValuesController>(c => c.GetValue(new TestRequest { Value = 1 }));
        }
    }
}
@Roemer
Copy link

Roemer commented May 11, 2022

We have a similar issue. With 1.2.6, the following did work:

                MyWebApi
                    .Routes()
                    .ShouldMap(requestUrl)
                    .WithHttpMethod(routesToActionMapPost.ContainsKey(routeActionPair.Key) ? HttpMethod.Post : HttpMethod.Get)
                    .ToAction(routeActionPair.Value);

and now with 1.3.0 it fails with the following error:

Expected route '/api/projects/54?var=20' to match 'Get' action but instead matched ''.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants