Why is the Get method missing in MoqMockingKernel?

I use the MoqMockingKernelfollowing example from the wiki , but the method is missing Get(). My simplified code:

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>();                      
        }
    }
}

What am I doing wrong here? It has GetHashCode(), GetMock(), GetModules()and GetType(), but not Get().

+4
source share
1 answer

Finally figured it out. Get()is an extension method that lives in the classroom Ninject.ResolutionExtensions. Adding using Ninject;solved the problem. None of the examples show which namespaces you need to use, which is disappointing.

+7
source

Source: https://habr.com/ru/post/1542724/


All Articles