Пример #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());
        }
Пример #2
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());
        }
Пример #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());
        }
Пример #4
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());
        }
Пример #5
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());
        }