public void GetSuccess() { _shoppingCartItemService.Setup(s => s.GetShoppingCartItem(It.IsAny <long>(), true)).Returns(It.IsAny <List <ShoppingCartItem> >()); var result = _controller.Get(1, true); Assert.NotNull(result); Assert.IsType <OkObjectResult>(result.Result); var httpObjResult = result.Result as OkObjectResult; Assert.NotNull(httpObjResult); Assert.True(httpObjResult.StatusCode == 200); }
public async void Get_Not_Exists() { ShoppingCartItemControllerMockFacade mock = new ShoppingCartItemControllerMockFacade(); mock.ServiceMock.Setup(x => x.Get(It.IsAny <int>())).Returns(Task.FromResult <ApiShoppingCartItemResponseModel>(null)); ShoppingCartItemController controller = new ShoppingCartItemController(mock.ApiSettingsMoc.Object, mock.LoggerMock.Object, mock.TransactionCoordinatorMock.Object, mock.ServiceMock.Object, mock.ModelMapperMock.Object); controller.ControllerContext = new ControllerContext(); controller.ControllerContext.HttpContext = new DefaultHttpContext(); IActionResult response = await controller.Get(default(int)); response.Should().BeOfType <StatusCodeResult>(); (response as StatusCodeResult).StatusCode.Should().Be((int)HttpStatusCode.NotFound); mock.ServiceMock.Verify(x => x.Get(It.IsAny <int>())); }