7.4.5 Creating the Product Repository; e.g. 7.14 Adding the Real Repository Binding
parent
5ec3a1b095
commit
17cf2e94ba
|
@ -8,6 +8,7 @@ using System.Web.Mvc;
|
||||||
using System.Web.Routing;
|
using System.Web.Routing;
|
||||||
using SportsStore.Domain.Abstract;
|
using SportsStore.Domain.Abstract;
|
||||||
using SportsStore.Domain.Entities;
|
using SportsStore.Domain.Entities;
|
||||||
|
using SportsStore.Domain.Concrete;
|
||||||
|
|
||||||
namespace SportsStore.WebUI.Infrastructure
|
namespace SportsStore.WebUI.Infrastructure
|
||||||
{
|
{
|
||||||
|
@ -29,16 +30,7 @@ namespace SportsStore.WebUI.Infrastructure
|
||||||
|
|
||||||
private void AddBindings()
|
private void AddBindings()
|
||||||
{
|
{
|
||||||
// Mock implementation of the IProductRepository Interface
|
ninjectKernel.Bind<IProductRepository>().To<EFProductRepository>();
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue