Beispiel #1
0
        public void RequiresPositiveAmount()
        {
            var request = new RefundRequest()
            {
                RefundMerchantReference = System.Guid.NewGuid().ToString(),
                Amount  = 0,
                OrderId = 123456,
                Note    = "Test refund"
            };

            //Throws when amount is zero
            Assert.ThrowsException <ArgumentOutOfRangeException>
            (
                () =>
            {
                request.Validate();
            }
            );

            request.Amount = -10;
            //Throws when amount is negative
            Assert.ThrowsException <ArgumentOutOfRangeException>
            (
                () =>
            {
                request.Validate();
            }
            );

            //Does not throw when amount is valid
            request.Amount = 10;
            request.Validate();
        }
Beispiel #2
0
        public void RequiresRefundReference()
        {
            var request = new RefundRequest()
            {
                RefundMerchantReference = null,
                Amount  = 10,
                OrderId = 123456,
                Note    = "Test refund"
            };

            //Throws when RefundReference is null
            Assert.ThrowsException <ArgumentNullException>
            (
                () =>
            {
                request.Validate();
            }
            );

            request.RefundMerchantReference = String.Empty;
            //Throws when RefundReference is empty string
            Assert.ThrowsException <ArgumentException>
            (
                () =>
            {
                request.Validate();
            }
            );

            //Does not throw when RefundReference is not empty
            request.RefundMerchantReference = System.Guid.NewGuid().ToString();
            request.Validate();
        }