public async Task DeleteDiscountSuccessfully() { //Arrange _mockDiscountRepository.Setup(x => x.DeleteDiscount(It.IsAny <string>())).ReturnsAsync(true); //Act var result = await _sut.DeleteDiscount(this.DesiredDiscount.ProductName); //Assert Assert.NotNull(result); var response = Assert.IsType <ActionResult <bool> >(result); var okResult = response.Result as OkObjectResult; Assert.True(Convert.ToBoolean(okResult.Value)); }
public async Task DeleteDiscount(string productName) { _repository.Setup(p => p.DeleteDiscount(productName)).ReturnsAsync(true); var coupon = await _controller.DeleteDiscount(productName); if (coupon.Result is OkObjectResult okResult) { Assert.AreEqual((int)HttpStatusCode.OK, okResult.StatusCode); } else { Assert.Fail(); } }
private void confrim_Click(object sender, EventArgs e) { string FoodId = tbId.Text; var DiscountResult = DiscountController.DeleteDiscount(FoodId); if (DiscountResult) { MessageBox.Show("Remove Discount Successfully"); var foodResult = FoodController.GetFood(FoodId); var DiscountResult1 = DiscountController.GetDiscount(FoodId); int a = foodResult.Price + DiscountResult1.Amount; var updatePrice = new { Id = FoodId, Price = a }; var updateResult = FoodController.UpdateFood2(updatePrice); } else { MessageBox.Show("Food Not Found", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }