Ejemplo n.º 1
0
        public void ProcessPayment_Success()
        {
            //Mock
            var mock = new Mock <IBankProcessor>();

            mock.Setup(x => x.Process(_payment)).Returns(Task.FromResult(new object()));
            //Arrange
            var validator = new ProcessPayment(mock.Object, _payment);
            //Act
            var result = validator.Process();

            //Assert
            Assert.AreEqual(result.StatusCode, StatusCode.Success);
            Assert.IsTrue(string.IsNullOrEmpty(result.StatusDetail));
            Assert.IsTrue(!string.IsNullOrEmpty(result.Status));
        }
Ejemplo n.º 2
0
        public void ProcessPayment_Exception_Failed()
        {
            //Mock
            var mock = new Mock <IBankProcessor>();

            mock.Setup(x => x.Process(_payment))
            .Returns(Task.FromResult(
                         new Exception("Test Failed") as object));
            //Arrange
            var validator = new ProcessPayment(mock.Object, _payment);
            //Act
            var result = validator.Process();

            //Assert
            Assert.AreEqual(result.StatusCode, StatusCode.Failed);
            Assert.AreEqual(result.ErrorCode, ErrorCode.PaymentFailed);
            Assert.IsTrue(!string.IsNullOrEmpty(result.StatusDetail));
            Assert.IsTrue(!string.IsNullOrEmpty(result.Status));
        }