Hi,
I'm new to Moq and learning.
I need to test that a method returns the value expected. I have put together a noddy example to explain my problem. This fails miserably with:
"ArgumentException: Expression is not a method invocation: c => (c.DoSomething("Jo", "Blog", 1) = "OK")"
Can you correct what I am doing wrong?
[TestFixtureAttribute, CategoryAttribute("Customer")]
public class Can_test_a_customer
{
[TestAttribute]
public void Can_do_something()
{
var customerMock = new Mock<ICustomer>();
customerMock.Setup(c => c.DoSomething("Jo", "Blog", 1)).Returns("OK");
customerMock.Verify(c => c.DoSomething("Jo", "Blog", 1)=="OK");
}
}
public interface ICustomer
{
string DoSomething(string name, string surname, int age);
}
public class Customer : ICustomer
{
public string DoSomething(string name, string surname, int age)
{
return "OK";
}
}
In a nutshell: if I wanted to test a method like the one above, and I know that I am expecting back an "OK", how would I write it using Moq?
Thanks for any suggestions.