public void ProductControllerIsAnApiController() { var prodSrvc = new Mock<IProductService>(); var jsonSrvc = new Mock<IJsonHttpResponseService>(); ProductController ctrl = new ProductController(prodSrvc.Object, jsonSrvc.Object); Assert.IsInstanceOfType(ctrl, typeof(ApiController)); }
public void ProductControllerListingMethodReturnsHttpResponseMessage() { var prodSrvc = new Mock<IProductService>(); ProductController ctrl = new ProductController(prodSrvc.Object, new JsonHttpResponseService()); var result = ctrl.Listing(); Assert.IsInstanceOfType(result, typeof(HttpResponseMessage)); }
public void ProductControllerConstructorRequiresProductService() { var prodSrvc = new Mock<IProductService>(); var jsonSrvc = new Mock<IJsonHttpResponseService>(); ProductController ctrl = new ProductController(prodSrvc.Object, jsonSrvc.Object); Assert.IsNotNull(ctrl); }
public void ProductControllerListingMethodReturnsJsonEnumerableOfProductModels() { var expResp = new JsonHttpResponseService().GetObjectHttpResponseMessage(makeProdList()); var prodSrvc = new Mock<IProductService>(); prodSrvc.Setup(s => s.Listing()).Returns(makeProdList()); ProductController ctrl = new ProductController(prodSrvc.Object, new JsonHttpResponseService()); var ctrlResp = ctrl.Listing(); TestHelpers.HttpRespStringsAreEqual(expResp, ctrlResp); }