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 does not setup write-only properties #835

Closed
ishimko opened this issue Jun 1, 2019 · 1 comment · Fixed by #836
Closed

SetupAllProperties does not setup write-only properties #835

ishimko opened this issue Jun 1, 2019 · 1 comment · Fixed by #836
Assignees
Labels
Milestone

Comments

@ishimko
Copy link
Contributor

ishimko commented Jun 1, 2019

Opening a new issue as per #826 (comment).

Steps to reproduce

public abstract class WriteOnlyProperty
{
   public abstract string Test { set; }
}

[Fact]
public void Write_only_property_should_be_ignored_by_SetupAllProperties()
{
   var mock = new Mock<WriteOnlyProperty>(MockBehavior.Strict);
   mock.SetupAllProperties();
	
   mock.Object.Test = "test";
}

Expected behavior
Test is passed, writing to Test property is ignored.

Actual behavior
Exception is thrown:

Moq.MockException : WriteOnlyProperty.Test = "test" invocation failed with mock behavior Strict.
All invocations on the mock must have a corresponding setup.
@stakx
Copy link
Contributor

stakx commented Jun 1, 2019

Assuming that changing the current behavior won't break any existing tests, I'm all for fixing this. Please feel free to submit a PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants