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

SetupAllProperties doesn't setup properties that don't have a setter #136

Closed
NGloreous opened this issue Oct 10, 2014 · 4 comments
Closed

Comments

@NGloreous
Copy link

NGloreous commented Oct 10, 2014

This is a regression from previous behavior. I think it was introduced by the change to fix this issue:

https://code.google.com/p/moq/issues/detail?id=199&can=1&q=SetupAllProperties

If I run the following code with version 3.1.416.3 it works fine but if I run it with the latest version 4.2.1409.1722 it fails with the error:

"MockException: IGet.GetOnly invocation failed with mock behavior Strict. All invocations on the mock must have a corresponding setup."

void Main()
{
    var mock = new Mock<IGet>(MockBehavior.Strict);
    mock.SetupAllProperties();

    Console.WriteLine(mock.Object.GetOnly);
}

public interface IGet
{
    string GetOnly { get; }
}

This is blocking my team from upgrading to the latest version. Hopefully this can be fixed because this is causing over 200 unit test failures when I try to upgrade.

Thanks!

@kzu
Copy link
Member

kzu commented Oct 10, 2014

Any chance that you can have a shot at sending a PR with a fix?

/kzu from mobile
On Oct 9, 2014 8:46 PM, "NGloreous" notifications@github.com wrote:

This is a regression from previous behavior. I think it was introduced by
the change to fix this issue:

https://code.google.com/p/moq/issues/detail?id=199&can=1&q=SetupAllProperties

If I run the following code with version 3.1.416.3 it works fine but if I
run it with the latest version 4.2.1409.1722 it fails with the error:

"MockException: IGet.GetOnly invocation failed with mock behavior Strict.
All invocations on the mock must have a corresponding setup."

void Main()
{
var mock = new Mock(MockBehavior.Strict);
mock.SetupAllProperties();

Console.WriteLine(mock.Object.GetOnly);

}

public interface IGet
{
string GetOnly { get; }
}

This is blocking my team from upgrading to the latest version. Hopefully
this can be fixed because this is causing over 200 unit test failures when
I try to upgrade.

Thanks!

Reply to this email directly or view it on GitHub
#136.

@NGloreous
Copy link
Author

I'll take a look this weekend and see if I can get it fixed.

@kzu
Copy link
Member

kzu commented Oct 14, 2014

Thanks!

/kzu from mobile
On Oct 14, 2014 12:31 PM, "NGloreous" notifications@github.com wrote:

I'll take a look this weekend and see if I can get it fixed.

Reply to this email directly or view it on GitHub
#136 (comment).

@NGloreous
Copy link
Author

Pull request with fix submitted.

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