こんにちは
クラスがあり、関連付けられた拡張メソッドがあります。
public class Person{
public int ID {get;set}
public string Name {get;set}
}
延長方法:
public static class Helper {
public static int GetToken(this Person person){
int id = 0;
//Something here is done to read token from another service...
return id;
}
}
今、私はRhinoを使用してこの方法をテストしようとしています
public void readPersonToken(int personId) {
var person = Person.GetPersonInfo(personId);//we consume a service here
Console.Writeline(person.GetToken());//get token is consuming another service
}
テストを作成していて、GetPersonInfo() を呼び出すインターフェイスが既にあるとします。
var _interface = MockRepository.GenerateMock<IMyInterface>();
そして主な期待は
_interface.Expect(x => x.GetPersonInfo(2))
.Return(new Person { ID=2, Name = "A Stubbed Monica!" });
拡張メソッド GetToken のテストを作成するにはどうすればよいですか?