Q:

MOQ - Why is below not mocking?

Anyone have any idea why below still calls YesService?
It almost seems like IYesService is considered separate to YesService..
Any ideas?
public interface IYesService
{
    string Hello();
}
public class YesService : IYesService
{
    public string Hello()
    {
        return "Yes";
    }

}

class Program
{

    static void Main(string[] args)
    {
        var _mock = new Mock<IYesService>();
        _mock.Setup(x => x.Hello()).Returns("No");

        var service = new YesService();
        var result = service.Hello();

        Console.Write(result);
        Console.ReadLine();
    }
}

A:

Because you don't use the _mock, you instantiate the YesService and call the method on that.
You can use mocking when you consume this interface:
public class ServiceUser
{
    private IYesService _yesService;

    public ServiceUser(IYesService yesService)
    {
        _yesService = yesService;
    }

    public string CallService()
    {
        return _yesService.Hello();
    }
}

Then use it like this:
var serviceMock = new Mock<IYesService>();
serviceMock.Setup(x => x.Hello()).Returns("No");

var service = new ServiceUser(serviceMock.Object);
var result = service.CallService();

