Skip to content

1.3.0 breaks tests #289

@aueelis

Description

@aueelis

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 }));
        }
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions