7.2 Making a Mock Repository; Listing 7-5 Adding the Mock IProductRepository Implementation in the NinjectDependencyResolver.cs File
This commit is contained in:
parent
889b3e7c49
commit
56a61c71c8
@ -4,7 +4,10 @@ using System.Linq;
|
|||||||
using System.Web;
|
using System.Web;
|
||||||
using System.Web.Mvc;
|
using System.Web.Mvc;
|
||||||
using System.Web.Services.Description;
|
using System.Web.Services.Description;
|
||||||
|
using Moq;
|
||||||
using Ninject;
|
using Ninject;
|
||||||
|
using SportsStore.Domain.Abstract;
|
||||||
|
using SportsStore.Domain.Entities;
|
||||||
|
|
||||||
namespace SportsStore.WebUI.Infrastructure
|
namespace SportsStore.WebUI.Infrastructure
|
||||||
{
|
{
|
||||||
@ -30,7 +33,15 @@ namespace SportsStore.WebUI.Infrastructure
|
|||||||
|
|
||||||
private void AddBindings()
|
private void AddBindings()
|
||||||
{
|
{
|
||||||
// put bindings here
|
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 }
|
||||||
|
});
|
||||||
|
|
||||||
|
kernel.Bind<IProductRepository>().ToConstant((mock.Object));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user