I have a mock that i have setup like this. I need to return the same value that was passed in to .CreatePersonName
mock.Setup(m => m.CreatePersonName(It.IsAny<PersonName>())) .Returns(// what do i put here?);
Mock objects allow you to mimic the behavior of classes and interfaces, letting the code in the test interact with them as if they were real. This isolates the code you're testing, ensuring that it works on its own and that no other code will make the tests fail.
mock.Setup(m => m.CreatePersonName(It.IsAny<PersonName>())) .Returns((PersonName p) => p);
Based on:
// access invocation arguments when returning a value mock.Setup(x => x.DoSomething(It.IsAny<string>())) .Returns((string s) => s.ToLower());
from https://github.com/Moq/moq4/wiki/Quickstart
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With