jeudi 31 mars 2016

Mock a method for test

Trying to mock a method that is called within another method.

public virtual bool hello(string name, int age)
{

    string lastName = GetLastName();
}

 public virtual string GetLastName() 
    {
        return "xxx"; 
    }

 Mock<program> name= new Mock<program>();
 name.Setup(x => x.GetLastName()).Returns("qqq");

I want the method GetLastName to always return "qqq".

Aucun commentaire:

Enregistrer un commentaire