public virtual bool isShopRequestValid(ShopAdminRequest request) { if (request == null || request.Password == null) { return(false); } return(true); }
public void isShopRequestValidReturnsTrue() { var dbMock = new Mock <IPurchaseRepository>(); var controller = new PurchasesController(dbMock.Object); var request = new ShopAdminRequest() { Password = "******", ShopId = 3 }; var result = controller.isShopRequestValid(request); Assert.True(result); }
public void GetChecksReturns403() { var request = new ShopAdminRequest(); var dbMock = new Mock <IPurchaseRepository>(); dbMock.Setup(f => f.isShopPasswordRight(request)).Returns(false); var controllerMock = new Mock <PurchasesController>(dbMock.Object); controllerMock.Setup(f => f.isShopRequestValid(request)).Returns(true); PurchasesController controller = controllerMock.Object; var result = controller.GetChecks(request); Assert.Equal(403, result.StatusCode); }
public JsonResult GetChecks(ShopAdminRequest request) { if (!isShopRequestValid(request)) { return(_Response.BadRequest()); } if (!_db.isShopPasswordRight(request)) { return(_Response.Forbid()); } List <CheckDTO> purchases = _db.GetChecks(request.ShopId); return(_Response.Ok(purchases)); }