public void ShouldDisplayBuyNow() { // Arrange BuyNowController controller = new BuyNowController(m_repository, m_httpRequest.Object); // Act ViewResult result = controller.BuyNow(1); // Assert Assert.AreEqual("", result.ViewName); Assert.IsTrue(result.ViewData.Model is PaymentViewData); Assert.AreNotEqual(null, ((PaymentViewData)result.ViewData.Model).Tx); }
public void ShouldCreateTxAndVerifyNumbers() { // Arrange BuyNowController controller = new BuyNowController(m_repository, m_httpRequest.Object); // Act controller.PayNow(1, BuyNowAction.Succeed); Transaction tx = m_repository.Get(1); // Assert Assert.IsFalse(String.IsNullOrEmpty(tx.Tx)); Assert.IsFalse(String.IsNullOrEmpty(tx.VerifySign)); Assert.AreEqual("Completed", tx.State); }
public void ShouldDisplayPaid() { // Arrange Transaction tx = m_repository.Get(1); tx.Tx = "hfjdhfsk"; tx.State = "Completed"; UnitOfWork.Commit(); BuyNowController controller = new BuyNowController(m_repository, m_httpRequest.Object); // Act ViewResult result = controller.Paid(1) as ViewResult; // Assert Assert.AreEqual("", result.ViewName); Assert.IsTrue(result.ViewData.Model is PaymentViewData); Assert.AreNotEqual(null, ((PaymentViewData)result.ViewData.Model).Tx); }
public void ShouldRedirectToPaidFromPayNow() { // Arrange BuyNowController controller = new BuyNowController(m_repository, m_httpRequest.Object); // Act ActionResult result = controller.PayNow(1, BuyNowAction.Succeed); // Assert Assert.IsTrue(result is RedirectToRouteResult); Assert.AreEqual("Paid", ((RedirectToRouteResult)result).RouteValues["action"]); Assert.AreEqual(1, (int)((RedirectToRouteResult)result).RouteValues["txId"]); }
public void ShouldNotSendIpnMessageIfNoUrl() { // Arrange BuyNowController controller = new BuyNowController(m_repository, m_httpRequest.Object); // Act controller.PayNow(1, BuyNowAction.Succeed); // Assert m_httpRequest.Verify(x => x.BeginSend(null, null), Times.Never()); }
public void ShouldThrowFromPayNowIfInvalidId() { // Arrange BuyNowController controller = new BuyNowController(m_repository, m_httpRequest.Object); // Act try { controller.PayNow(99, BuyNowAction.Succeed); } catch (ErrorDataException) { return; } // Assert Assert.Fail("Should have thrown"); }
public void ShouldSetStatusToFailed() { // Arrange BuyNowController controller = new BuyNowController(m_repository, m_httpRequest.Object); // Act controller.PayNow(1, BuyNowAction.Fail); Transaction tx = m_repository.Get(1); // Assert Assert.AreEqual("Failed", tx.State); }
public void ShouldSendIpnMessage() { // Arrange BuyNowController controller = new BuyNowController(m_repository, m_httpRequest.Object); Transaction tx = m_repository.Get(1); tx.IpnReturnUrl = "http://test.com/"; UnitOfWork.Commit(); // Act controller.PayNow(1, BuyNowAction.Succeed); // Assert m_httpRequest.Verify(x => x.BeginSend(null, null)); }