With the test, you make sure that the greeter is used by the client, no more no less. (Unit tests can't replace integration tests).
But to emphasize this in the test, I usually introduce a constant in the test that doesn't output a text that a real implementation would do, e.g.:
public class ClientTests
{
pubic void Test()
{
const string TEXT_FROM_GREETER="Some nice formatted text from Greeter");
var mock = new Mock<IGreeter>();
mock.Setup(greeter => greeter.Greet("John", "Mr.")).Returns(TEXT_FROM_GREETER);
var result = new Client(mock.Object).FormatPageHeader("John", "Mr.");
Assert.AreEquals(result, TEXT_FROM_GREETER);
}
}
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
There is nothing wrong in your example.
With the test, you make sure that the greeter is used by the client, no more no less. (Unit tests can't replace integration tests).
But to emphasize this in the test, I usually introduce a constant in the test that doesn't output a text that a real implementation would do, e.g.: