Skip to content

Mocking ICountryFactory is impossible #57

@gharizanov

Description

@gharizanov

I’m trying to mock ICountryFactory but with no luck. Here is the code:

    var _countryFactory = new Mock<ICountryFactory>();

        _countryFactory
            .Setup(f => f.CreateCountry(It.IsAny<string>()))
            .Returns(new Country
            {
                Name = "Switzerland"
            });

And then I get these errors:

  • The type 'PostalCodes.Country' has no constructors defined
  • Property or indexer 'Name' cannot be assigned to -- it is read only

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions