代码逻辑如下:
func (c *Auth) ensureCredential() (azcore, error) { _, err = c.build(authData) } func (c *Auth) build(authData []byte) (*Client, error) { return NewClient() }
我要复制的C#代码
public async Task test() { var auth = new Auth(); var inner = await _cre(auth); // This part code I want to copy Client client = inner as Client Assert some values equals Client's fileds } public async Task<azcore> _credential(Auth provider) { await provider.EnsureCredential(IsAsync, default); return (azcore)typeof(Auth).GetField("_cre", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(provider); }
类型
Auth
和Client
都实现接口azcore
。我想让Auth
as
Client
,以便测试Auth
中的某些值是否等于Client
的字段。Auth
中的那些值将根据我的代码逻辑分配给Client
的字段。提前感谢。
代码逻辑如下:func(c * Auth)sureCredential()(azcore,error){_,err = c.build(authData)} func(c * Auth)build(authData [] byte)(* Client,错误){return NewClient()} C#代码I ...
在Go接口中隐式实现。