如何为内部 Class 中的方法编写测试方法?

how to write test method for a method which is inside an internal Class?

我有一个内部的class,里面有多个方法,我想为每个方法写一个Nunit,我该如何调用这些方法? 注意:此方法有接口。

示例代码:

internal class Sample : ISsample
{
    public string getValueabc(int a, int b)
    {
        String h="Value:"+a+"and another:"+b;
        return h;
    }
}

您可以 return 这个 class 来自其他公开可用的方法,例如:

public class MySampleFactory
{
    public ISample CreateSample()
    {
        return new Sample();
    }
}

//Inside a Unit Test
ISample sample = mySampleFactory.CreateSample();
sample.getValueAbc();