7.4.5 Creating the Product Repository; e.g. 7.14 Adding the Real Repository Binding

chap07
Jason Zhu 2021-08-21 16:07:45 +10:00
parent 5ec3a1b095
commit 17cf2e94ba
1 changed files with 2 additions and 10 deletions

View File

@ -8,6 +8,7 @@ using System.Web.Mvc;
using System.Web.Routing;
using SportsStore.Domain.Abstract;
using SportsStore.Domain.Entities;
using SportsStore.Domain.Concrete;
namespace SportsStore.WebUI.Infrastructure
{
@ -29,16 +30,7 @@ namespace SportsStore.WebUI.Infrastructure
private void AddBindings()
{
// Mock implementation of the IProductRepository Interface
Mock<IProductRepository> mock = new Mock<IProductRepository>();
mock.Setup(m => m.Products).Returns(new List<Product>
{
new Product { Name = "Football", Price = 25 },
new Product { Name = "Surf board", Price = 179 },
new Product { Name = "Running shoes", Price = 95 }
}.AsQueryable());
ninjectKernel.Bind<IProductRepository>().ToConstant(mock.Object);
ninjectKernel.Bind<IProductRepository>().To<EFProductRepository>();
}
}
}