为什么MoqMockingKernel中缺少Get方法?

Mik*_*e B 4 c# ninject moq

我正在使用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>();                      
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

我在这做错了什么?它有GetHashCode(),GetMock(),GetModules(),和GetType(),但没有Get().

Mik*_*e B 7

终于想通了.Get()是一种生活在Ninject.ResolutionExtensions课堂上的扩展方法.添加using Ninject;解决了问题.这些示例都没有显示您需要使用哪些名称空间令人沮丧.

  • 感谢那..Net代码示例受到"猜测哪个随机命名空间放入扩展方法"的困扰. (2认同)
  • 非常感谢,为我节省了几分钟:) (2认同)