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

Moq should use CallBase to call default method from interfaces #1345

Closed
alex-fomin opened this issue Jun 8, 2023 · 1 comment
Closed

Moq should use CallBase to call default method from interfaces #1345

alex-fomin opened this issue Jun 8, 2023 · 1 comment

Comments

@alex-fomin
Copy link

The code example fails and there is no possibility to use default interface implementation in a mock.

void Main()
{
	var m = new Mock<IFoo>(MockBehavior.Strict)
	{
		CallBase = true
	};
	
	m.SetupGet(x => x.Bar).Returns(5);
	
// UserQuery.IFoo.Baz invocation failed with mock behavior Strict.
// All invocations on the mock must have a corresponding setup.
	Console.WriteLine(m.Object.Baz);
}

public interface IFoo {
	int Bar { get; }
	int Baz => Bar + 1;
}
@alex-fomin
Copy link
Author

Sorry, duplicate with #1334

@alex-fomin alex-fomin closed this as not planned Won't fix, can't repro, duplicate, stale Jun 8, 2023
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

1 participant