Exemple #1
0
        public void TestMerchantInfoPasswordValidation()
        {
            // Required.

            var message = new EchoRequestMessage(
                CreateMessageInfo(),
                new RequestMerchantInfo {
                MerchantId = MerchantId, Password = null
            });

            AssertValidationErrors(message.GetValidationErrors(), new RequiredValidationError("Password"));

            // Invalid.

            message.MerchantInfo.Password = "******";
            AssertValidationErrors(message.GetValidationErrors(), new LengthRangeValidationError("Password", 6, 20));

            message.MerchantInfo.Password = new string('a', 30);
            AssertValidationErrors(message.GetValidationErrors(), new LengthRangeValidationError("Password", 6, 20));

            // Valid.

            message.MerchantInfo.Password = Password;
            AssertValidationErrors(message.GetValidationErrors());
        }
Exemple #2
0
        public async Task <EchoResponseMessage> EchoAsync()
        {
            var echoRequestMessage       = new EchoRequestMessage();
            EchoResponseMessage response = await PostAsync <EchoRequestMessage, EchoResponseMessage>(echoRequestMessage);

            return(response);
        }
Exemple #3
0
        public void TestMerchantInfoMerchantIdValidation()
        {
            // Required.

            var message = new EchoRequestMessage(
                CreateMessageInfo(),
                new RequestMerchantInfo {
                MerchantId = null, Password = "******"
            });

            AssertValidationErrors(message.GetValidationErrors(), new RequiredValidationError("MerchantId"));

            // Invalid.

            message.MerchantInfo.MerchantId = "ABC001";
            AssertValidationErrors(message.GetValidationErrors(), new LengthValidationError("MerchantId", 7));

            message.MerchantInfo.MerchantId = "ABC00001";
            AssertValidationErrors(message.GetValidationErrors(), new LengthValidationError("MerchantId", 7));

            // Valid.

            message.MerchantInfo.MerchantId = MerchantId;
            AssertValidationErrors(message.GetValidationErrors());
        }
Exemple #4
0
        public void TestMessageInfoApiVersionValidation()
        {
            // Required.

            var message = new EchoRequestMessage(
                new RequestMessageInfo
            {
                MessageId        = MessageId.NewMessageId(),
                MessageTimestamp = new MessageTimestamp(DateTime.Now),
                Timeout          = 60
            },
                CreateMerchantInfo(false));

            AssertValidationErrors(message.GetValidationErrors(), new RequiredValidationError("ApiVersion"));

            // Invalid.

            message.MessageInfo.ApiVersion = "xml-4.3";
            AssertValidationErrors(message.GetValidationErrors(), new RegexValidationError("ApiVersion"));

            // Valid.

            message.MessageInfo.ApiVersion = ApiVersion;
            AssertValidationErrors(message.GetValidationErrors());
        }
Exemple #5
0
        public void TestMessageInfoTimeoutValueValidation()
        {
            // Required.

            var message = new EchoRequestMessage(
                new RequestMessageInfo
            {
                MessageId        = MessageId.NewMessageId(),
                MessageTimestamp = new MessageTimestamp(DateTime.Now),
                ApiVersion       = ApiVersion
            },
                CreateMerchantInfo(false));

            AssertValidationErrors(message.GetValidationErrors(), new NumericValueRangeValidationError("Timeout", 1, 999));

            // Invalid.

            message.MessageInfo.Timeout = -23;
            AssertValidationErrors(message.GetValidationErrors(), new NumericValueRangeValidationError("Timeout", 1, 999));

            message.MessageInfo.Timeout = 1050;
            AssertValidationErrors(message.GetValidationErrors(), new NumericValueRangeValidationError("Timeout", 1, 999));

            // Valid.

            message.MessageInfo.Timeout = 60;
            AssertValidationErrors(message.GetValidationErrors());
        }
Exemple #6
0
        public void TestMerchantInfoDefaults()
        {
            var message = new EchoRequestMessage();

            Assert.AreEqual(null, message.MerchantInfo.MerchantId);
            Assert.AreEqual(null, message.MerchantInfo.Password);

            message.Prepare();
            Assert.AreEqual(null, message.MerchantInfo.MerchantId);
            Assert.AreEqual(null, message.MerchantInfo.Password);
        }
        public void TestCloneRequestMessage()
        {
            // Serialize.

            var message = new EchoRequestMessage(CreateMessageInfo(), CreateMerchantInfo(false));

            message.Prepare();
            var serializedMessage = Serialization.Serialize((EchoRequestMessage)message.Clone());

            // Check.

            AssertRequestMessage(message, serializedMessage);
        }
Exemple #8
0
        public void TestMessageInfoDefaults()
        {
            var message = new EchoRequestMessage();

            Assert.AreEqual(null, message.MessageInfo.MessageId);
            Assert.AreEqual(null, message.MessageInfo.MessageTimestamp);
            Assert.AreEqual(0, message.MessageInfo.Timeout);
            Assert.AreEqual(null, message.MessageInfo.ApiVersion);

            message.Prepare();
            Assert.IsNotNull(message.MessageInfo.MessageId);
            Assert.IsNotNull(message.MessageInfo.MessageTimestamp);
            Assert.AreEqual(60, message.MessageInfo.Timeout);
            Assert.AreEqual("xml-4.2", message.MessageInfo.ApiVersion);
        }
        public void TestEchoMessage()
        {
            // Request.

            var requestMessage = new EchoRequestMessage(CreateMessageInfo(), CreateMerchantInfo(false));

            requestMessage.Prepare();

            // Response.

            var responseMessage = GetCommand().Send(requestMessage);

            // Check.

            AssertResponse(responseMessage);
            AssertRequestResponse(requestMessage, responseMessage);
        }
Exemple #10
0
        public void TestMessageInfoMessageTimestampValidation()
        {
            // Required.

            var message = new EchoRequestMessage(
                new RequestMessageInfo
            {
                MessageId  = MessageId.NewMessageId(),
                Timeout    = 60,
                ApiVersion = ApiVersion
            },
                CreateMerchantInfo(false));

            AssertValidationErrors(message.GetValidationErrors(), new RequiredValidationError("MessageTimestamp"));

            // Valid.

            message.MessageInfo.MessageTimestamp = new MessageTimestamp(DateTime.Now);
            AssertValidationErrors(message.GetValidationErrors());
        }
 EchoResponseMessage ISendSecurePayCommand.Send(EchoRequestMessage requestMessage)
 {
     throw new NotImplementedException();
 }