Skip to content
This repository was archived by the owner on May 19, 2024. It is now read-only.
This repository was archived by the owner on May 19, 2024. It is now read-only.

Test fails saying action parameter doesn't match. #55

@zagnut999

Description

@zagnut999

I'm trying to write a fluent test that will test the parameter values passed to the action. Below is the code I used and am not getting the results I expected. In the route I am adding overrideImageFormat to the defaults object, but it is not being used by the test. The code below but inside a VS project can be found here: https://www.dropbox.com/s/ao4ksxw6xwsqxxp/MvcRouteTesterIssue.zip?dl=0

    public class ImageTestController : Controller
    {
        public ActionResult Icon(IconTestModel model, ImageFormat overrideImageFormat = null)
        {
            return Content("");
        }
    }

    public class IconTestModel
    {
        public string Name { get; set; }
        public string OverlayName { get; set; }
    }

    [TestMethod]
    public void Test()
    {
        var routes = new RouteCollection();
        var route = routes.MapRoute(
            name: "Icon", url: "Icon/{name}",
            defaults: new
            {
                controller = "ImageTest", action = "Icon",
                overrideImageFormat = ImageFormat.Png,
            }
        );
        route.DataTokens["area"] = "Common";

        routes
            .ShouldMap("/icon/name")
            .To<ImageTestController>(ctrl => ctrl.Icon(new IconTestModel { Name = "name" }, ImageFormat.Png));
    }

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