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.

Assertions on Json body fail if class has enum property. #62

@phatcher

Description

@phatcher

Given a class with an enum the assertion fails if you convert the entity to json to get the post body, e.g.

    [TestMethod]
    public void PackagePost()
    {
        var package = new Package();

        var packageJson = JsonConvert.SerializeObject(package);
        config.ShouldMap("/api/Package")
              .WithJsonBody(packageJson)
              .To<PackageController>(HttpMethod.Post, x => x.Post(package));
    }

    [TestMethod]
    public void PackagePostJson2()
    {
        var package = new Package();

        var packageJson = "{ Logging: 'Basic', Synchronous: 'false' }";
        config.ShouldMap("/api/Package")
              .WithJsonBody(packageJson)
              .To<PackageController>(HttpMethod.Post, x => x.Post(package));
    }

The issue is that the PropertyReader.GetPropertyValue gets the enum representation rather than the json representation of the value so it fails as 'Basic' != 1.

Sorry for the incomplete repro but this should give the basic idea of the issue.

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