我正在使用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().
终于想通了.Get()是一种生活在Ninject.ResolutionExtensions课堂上的扩展方法.添加using Ninject;解决了问题.这些示例都没有显示您需要使用哪些名称空间令人沮丧.
| 归档时间: |
|
| 查看次数: |
491 次 |
| 最近记录: |