public InventoryController()
        {
            Web.App_Start.MapperConfig.Configure();
            _newEatable = new Web.Models.Eatable {
                Name = "new-eatable", Price = 0.1M
            };
            _inventoryServiceMock = new Mock <IInventoryService>();
            _eatableValidatorMock = new Mock <IEatableValidator>();
            _mockInventoryList    = CreatMockInventoryList();

            _eatableValidatorMock.Setup(e => e.IsValid(It.IsAny <Web.Models.EatableInput>())).Returns(true);
            _inventoryServiceMock.Setup(i => i.Get()).Returns(_mockInventoryList);
            _inventoryServiceMock.Setup(i => i.Get(It.IsAny <int>())).Returns(_mockInventoryList.FirstOrDefault());
            _inventoryServiceMock.Setup(i => i.Insert(It.IsAny <Web.Models.Eatable>())).Returns(_newEatable);
            _inventoryServiceMock.Setup(i => i.Remove(It.IsAny <int>()));
            _inventoryServiceMock.Setup(i => i.Update(It.IsAny <int>(), It.IsAny <Web.Models.Eatable>()));

            _controller = new Web.Controllers.InventoryController(
                _inventoryServiceMock.Object,
                _eatableValidatorMock.Object);
        }
Beispiel #2
0
 public InventoryService()
 {
     _inventoryService = new ALServices.InventoryService();
     _eatable          = CreateEatable();
 }