【发布时间】:2019-01-04 16:47:43
【问题描述】:
我正在尝试对这个返回 Action<SomeOptions> 的方法进行单元测试。
public class MyOption
{
public Action<SomeOptions> GetOptions()
{
return new Action<SomeOptions>(o =>
{
o.Value1 = "abc";
o.Value2 = "def";
}
);
}
}
我想在我的测试中验证 Value1 是 "abc" 和 Value2 是 "def"
[Test]
public void GetOptions_ReturnsExpectedOptions()
{
var option = new MyOption();
Action<SomeOptions> result = option.GetOptions();
//Assert
Assert.IsNotNull(result);
//I also want to verify that the result has Value1="abc" & Value2 = "def"
}
我不确定如何测试验证结果是否具有Value1="abc" 和Value2 = "def" 的那部分代码
【问题讨论】:
-
调用返回的动作并分配结果,然后验证结果。
标签: c# unit-testing asp.net-core