【发布时间】:2017-09-26 22:25:57
【问题描述】:
我们如何在不实例化测试类中的对象的情况下测试 void 方法?我了解在内部静态类中,我们无法使用“new”来创建对象来测试它。我已经通过为非静态类创建对象进行了单元测试,但我还没有处理内部静态类并且被卡住了。任何指导都会很棒。
这是有问题的类/方法:
internal static class Util
{
public static void AssertBytesEqual(byte[] expected, byte[] actual)
{
if (expected.Length != actual.Length)
{
Debugger.Break();
throw new CryptographicException("The bytes were not of the expected length.");
}
for (int i = 0; i < expected.Length; i++)
{
if (expected[i] != actual[i])
{
Debugger.Break();
throw new CryptographicException("The bytes were not identical.");
}
}
}
}
【问题讨论】:
标签: c# unit-testing testing methods void