小编Ale*_*x K的帖子

模拟存储过程的输出参数

我有以下方法

public bool IsUserAllowedToDoThings(string userName, string thingToDo)
    {
        var outputParameter = new ObjectParameter("IsAllowed", typeof(bool?));
        _context.SP_IsUserAllowedToDoThings(userName, thingToDo, outputParameter);
        return (bool)outputParameter.Value;
    }
Run Code Online (Sandbox Code Playgroud)

该方法只是使用 EF 调用 SP 并返回 SP 的输出结果。但是我在模拟 SP 的输出进行单元测试时遇到了问题。PS 我正在使用 MOQ 框架进行模拟。

.net c# unit-testing moq mocking

5
推荐指数
1
解决办法
2610
查看次数

标签 统计

.net ×1

c# ×1

mocking ×1

moq ×1

unit-testing ×1