public void PaymentController_DoPayment_NullReferenceException_Failed() { //Arrange var controller = new PaymentController(_mockActService.Object, _log); //Act and Assert Assert.ThrowsExceptionAsync <NullReferenceException>(() => controller.DoPayment(new ApiModel.Payment { ProductName = "Exception" }), "Test Null Exception."); }
public void PaymentController_DoPayment_Null_Failed() { //Arrange var controller = new PaymentController(_mockActService.Object, _log); //Act var result = controller.DoPayment(null).Result; //Assert Assert.IsNotNull(result); Assert.IsFalse(result.Success); Assert.IsTrue(result.TotalRecords == 0); Assert.IsNull(result.Data); Assert.IsTrue(string.IsNullOrEmpty(result.ErrorCode)); Assert.IsTrue(string.IsNullOrEmpty(result.ErrorMessage)); Assert.IsTrue(string.IsNullOrEmpty(result.ErrorStackTrace)); }
public void PaymentController_DoPayment_Error_Failed() { //Arrange var controller = new PaymentController(_mockActService.Object, _log); //Act var result = controller.DoPayment(new ApiModel.Payment()).Result; //Assert Assert.IsNotNull(result); Assert.IsFalse(result.Success); Assert.IsTrue(result.TotalRecords == 1); Assert.IsNotNull(result.Data); Assert.IsTrue(((Result)result.Data).ErrorCode == ErrorCode.PaymentFailed); Assert.IsTrue(((Result)result.Data).StatusCode == StatusCode.Failed); Assert.IsTrue(result.ErrorCode == "301"); Assert.IsTrue(!string.IsNullOrEmpty(result.ErrorMessage)); }
public void PaymentController_DoPayment_Successful() { //Arrange var controller = new PaymentController(_mockActService.Object, _log); //Act var result = controller.DoPayment(_apiPayment).Result; //Assert Assert.IsNotNull(result); Assert.IsTrue(result.Success); Assert.IsTrue(result.TotalRecords == 1); Assert.IsNotNull(result.Data); Assert.IsInstanceOfType(result.Data, typeof(ApiModel.Payment)); Assert.AreEqual(((ApiModel.Payment)result.Data).PaymentId, _repoPayment.PaymentId); Assert.IsTrue(string.IsNullOrEmpty(result.ErrorCode)); Assert.IsTrue(string.IsNullOrEmpty(result.ErrorMessage)); Assert.IsTrue(string.IsNullOrEmpty(result.ErrorStackTrace)); }
private void btnPay_Click(object sender, EventArgs e) { _paymentController.DoPayment(_tableId); }