public void Should_Success_Get_Stock() { var validateMock = new Mock <IValidateService>(); validateMock.Setup(s => s.Validate(It.IsAny <InventoryViewModel>())).Verifiable(); var mockFacade = new Mock <InventoryFacade>(); mockFacade.Setup(x => x.getStock(It.IsAny <int>(), It.IsAny <int>())) .Returns(Model); var mockMapper = new Mock <IMapper>(); mockMapper.Setup(x => x.Map <List <InventoryViewModel> >(It.IsAny <List <Inventory> >())) .Returns(new List <InventoryViewModel> { ViewModel }); InventoriesController controller = GetController(mockFacade, validateMock, mockMapper); var response = controller.GetStock(It.IsAny <int>(), It.IsAny <int>()); Assert.Equal((int)HttpStatusCode.OK, GetStatusCode(response)); }
public void Should_Error_Get_Stock() { var validateMock = new Mock <IValidateService>(); validateMock.Setup(s => s.Validate(It.IsAny <InventoryViewModel>())).Verifiable(); var mockFacade = new Mock <InventoryFacade>(); mockFacade.Setup(x => x.getStock(It.IsAny <int>(), It.IsAny <int>())) .Returns(Model); var mockMapper = new Mock <IMapper>(); mockMapper.Setup(x => x.Map <List <InventoryViewModel> >(It.IsAny <List <Inventory> >())) .Returns(new List <InventoryViewModel> { ViewModel }); InventoriesController controller = new InventoriesController(mockMapper.Object, mockFacade.Object, GetServiceProvider().Object); var response = controller.GetStock(It.IsAny <int>(), It.IsAny <int>()); Assert.Equal((int)HttpStatusCode.InternalServerError, GetStatusCode(response)); }