gpt4 book ai didi

c# - 为什么 MoqMockingKernel 中缺少 Get 方法?

转载 作者:太空狗 更新时间:2023-10-30 00:40:55 26 4
gpt4 key购买 nike

我在 example from the wiki 之后使用 MoqMockingKernel但是缺少 Get() 方法。我的简化代码:

using Moq;
using Ninject.MockingKernel.Moq;

namespace Store.Web.Tests.Controllers
{
[TestClass]
public class PeopleControllerTests
{
private MoqMockingKernel _mockingKernel;

[TestInitialize]
public void SetUp()
{
_mockingKernel = new MoqMockingKernel();
}

[TestMethod]
public void AddAnotherPersonAddsAnotherPerson()
{
// There is no Get method on _mockingKernel
var peopleController = _mockingKernel.Get<PeopleController>();
}
}
}

我在这里做错了什么?它有 GetHashCode()GetMock()GetModules()GetType() 但没有 获取()

最佳答案

终于明白了。 Get() 是位于 Ninject.ResolutionExtensions 类中的扩展方法。添加 using Ninject; 解决了这个问题。没有一个示例显示您需要使用哪些 namespace ,这令人沮丧。

关于c# - 为什么 MoqMockingKernel 中缺少 Get 方法?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23964850/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com