Beispiel #1
0
        public void Notify_Verify_Invalid()
        {
            // Arrange
            var partner      = "2088123456789012";
            var responseText = "false";
            var notifyId     = "123";

            var notifyService = new FackNotifyService(() => responseText);

            var dict = new Dictionary <string, string>();

            dict.Add("notify_id", notifyId);

            var config = new AlipayConfig
            {
                Partner = partner,
            };

            // Act
            var notify = new DirectPayNotify(notifyService, dict, config);

            // Assert
            Assert.IsNotNull(notify);

            Assert.AreEqual(notifyId, notify.NotifyID);

            Assert.AreEqual(config, notify.Config);

            Assert.AreEqual(false, notify.Verify());
        }
Beispiel #2
0
        public void Notify_Verify_Valid()
        {
            // Arrange
            var partner      = "2088123456789012";
            var responseText = "true";
            var notifyId     = "123";
            var sign         = "4652a3fdd86f1544fa5f91204c2b7ac1";

            var notifyService = new FackNotifyService(() => responseText);

            var dict = new Dictionary <string, string>();

            dict.Add("notify_id", notifyId);
            dict.Add("sign", sign);

            var config = new AlipayConfig
            {
                Partner = partner,
            };

            // Act
            var notify = new DirectPayNotify(notifyService, dict, config);

            // Assert
            Assert.IsNotNull(notify);

            Assert.AreEqual(notifyId, notify.NotifyID);

            Assert.AreEqual(dict.Count, notify.Parameters.Count);
            Assert.AreEqual(config, notify.Config);

            Assert.AreEqual(sign, notify.GenerateSignature());
            Assert.AreEqual(true, notify.Verify());
        }