Пример #1
0
        public void TestInitialization()
        {
            Dictionary <String, String> mockConfig = new Dictionary <string, string>();

            mockConfig["url"]               = "https://www.mockurl.com";
            mockConfig["reportGroup"]       = "Mock Report Group";
            mockConfig["username"]          = "******";
            mockConfig["printxml"]          = "false";
            mockConfig["timeout"]           = "35";
            mockConfig["proxyHost"]         = "www.mockproxy.com";
            mockConfig["merchantId"]        = "MOCKID";
            mockConfig["password"]          = "******";
            mockConfig["proxyPort"]         = "3000";
            mockConfig["sftpUrl"]           = "www.mockftp.com";
            mockConfig["sftpUsername"]      = "******";
            mockConfig["sftpPassword"]      = "******";
            mockConfig["onlineBatchUrl"]    = "www.mockbatch.com";
            mockConfig["onlineBatchPort"]   = "4000";
            mockConfig["requestDirectory"]  = Path.Combine(Path.GetTempPath(), "MockRequests");;
            mockConfig["responseDirectory"] = Path.Combine(Path.GetTempPath(), "MockResponses");;

            rfrRequest = new RFRRequest(mockConfig);

            Assert.AreEqual(Path.Combine(Path.GetTempPath(), "MockRequests", "Requests") + Path.DirectorySeparatorChar, rfrRequest.getRequestDirectory());
            Assert.AreEqual(Path.Combine(Path.GetTempPath(), "MockResponses", "Responses") + Path.DirectorySeparatorChar, rfrRequest.getResponseDirectory());

            Assert.NotNull(rfrRequest.getCnpTime());
            Assert.NotNull(rfrRequest.getCnpFile());
        }
        public void testInitialization()
        {
            var mockConfig = new Dictionary <string, string>();

            mockConfig["url"]               = "https://www.mockurl.com";
            mockConfig["reportGroup"]       = "Mock Report Group";
            mockConfig["username"]          = "******";
            mockConfig["printxml"]          = "false";
            mockConfig["timeout"]           = "35";
            mockConfig["proxyHost"]         = "www.mockproxy.com";
            mockConfig["merchantId"]        = "MOCKID";
            mockConfig["password"]          = "******";
            mockConfig["proxyPort"]         = "3000";
            mockConfig["sftpUrl"]           = "www.mockftp.com";
            mockConfig["sftpUsername"]      = "******";
            mockConfig["sftpPassword"]      = "******";
            mockConfig["knownHostsFile"]    = "C:\\MockKnownHostsFile";
            mockConfig["onlineBatchUrl"]    = "www.mockbatch.com";
            mockConfig["onlineBatchPort"]   = "4000";
            mockConfig["requestDirectory"]  = "C:\\MockRequests";
            mockConfig["responseDirectory"] = "C:\\MockResponses";

            rfrRequest = new RFRRequest(_memoryCache, mockConfig);

            Assert.AreEqual("C:\\MockRequests\\Requests\\", rfrRequest.getRequestDirectory());
            Assert.AreEqual("C:\\MockResponses\\Responses\\", rfrRequest.getResponseDirectory());

            Assert.NotNull(rfrRequest.getLitleTime());
            Assert.NotNull(rfrRequest.getLitleFile());
        }
Пример #3
0
        public string SerializeRFRRequestToFile(RFRRequest rfrRequest, string filePath)
        {
            filePath = cnpFile.createRandomFile(requestDirectory, Path.GetFileName(filePath), "_temp_cnpRequest.xml", cnpTime);
            var tempFilePath = rfrRequest.Serialize();

            cnpFile.AppendFileToFile(filePath, tempFilePath);

            return(filePath);
        }
Пример #4
0
        public void addRFRRequest(RFRRequest rfrRequest)
        {
            if (numOfCnpBatchRequest != 0)
            {
                throw new CnpOnlineException("Can not add an RFRRequest to a batch with requests!");
            }
            else if (numOfRFRRequest >= 1)
            {
                throw new CnpOnlineException("Can not add more than one RFRRequest to a batch!");
            }

            batchFilePath = SerializeRFRRequestToFile(rfrRequest, batchFilePath);
            numOfRFRRequest++;
        }
Пример #5
0
        public void addRFRRequest(RFRRequest rfrRequest)
        {
            // Throw an exception for non-RFRrequests and existing RFRrequests
            if (this.numOfCnpBatchRequest != 0)
            {
                throw new CnpOnlineException("Can not add an RFRRequest to a batch with requests!");
            }
            else if (this.numOfRFRRequest >= 1)
            {
                throw new CnpOnlineException("Can not add more than one RFRRequest to a batch!");
            }

            // Add the request.
            this.rfrRequest = rfrRequest;
            this.numOfRFRRequest++;
        }
 public void setUpBeforeTest()
 {
     rfrRequest = new RFRRequest(_memoryCache);
 }
Пример #7
0
 public void SetUpBeforeTest()
 {
     rfrRequest = new RFRRequest();
 }
        public void RFRBatch()
        {
            var litleBatchRequest = new batchRequest(memoryStreams);
            litleBatchRequest.id = "1234567A";

            var accountUpdate1 = new accountUpdate();
            accountUpdate1.orderId = "1111";
            var card = new cardType();
            card.type = methodOfPaymentTypeEnum.VI;
            card.number = "4242424242424242";
            card.expDate = "1210";
            accountUpdate1.card = card;

            litleBatchRequest.addAccountUpdate(accountUpdate1);

            var accountUpdate2 = new accountUpdate();
            accountUpdate2.orderId = "1112";
            accountUpdate2.card = card;

            litleBatchRequest.addAccountUpdate(accountUpdate2);

            litle.addBatch(litleBatchRequest);
            var litleResponse = litle.sendToLitleWithStream();

            Assert.NotNull(litleResponse);

            var litleBatchResponse = litleResponse.nextBatchResponse();
            Assert.NotNull(litleBatchResponse);
            while (litleBatchResponse != null)
            {
                var accountUpdateResponse = litleBatchResponse.nextAccountUpdateResponse();
                Assert.NotNull(accountUpdateResponse);
                while (accountUpdateResponse != null)
                {
                    Assert.AreEqual("000", accountUpdateResponse.response);

                    accountUpdateResponse = litleBatchResponse.nextAccountUpdateResponse();
                }
                litleBatchResponse = litleResponse.nextBatchResponse();
            }

            var litleRfr = new litleRequest(memoryStreams);
            var rfrRequest = new RFRRequest(memoryStreams);
            var accountUpdateFileRequestData = new accountUpdateFileRequestData();
            accountUpdateFileRequestData.merchantId = Settings.Default.merchantId;
            accountUpdateFileRequestData.postDay = DateTime.Now;
            rfrRequest.accountUpdateFileRequestData = accountUpdateFileRequestData;

            litleRfr.addRFRRequest(rfrRequest);

            try
            {
                var litleRfrResponse = litleRfr.sendToLitleWithStream();
                Assert.NotNull(litleRfrResponse);

                var rfrResponse = litleRfrResponse.nextRFRResponse();
                Assert.NotNull(rfrResponse);
                while (rfrResponse != null)
                {
                    Assert.AreEqual("1", rfrResponse.response);
                    Assert.AreEqual("The account update file is not ready yet.  Please try again later.",
                        rfrResponse.message);
                    rfrResponse = litleResponse.nextRFRResponse();
                }
            }
            catch (Exception)
            {
            }
        }
        public void testInitialization()
        {
            var mockConfig = new Dictionary<string, string>();

            mockConfig["url"] = "https://www.mockurl.com";
            mockConfig["reportGroup"] = "Mock Report Group";
            mockConfig["username"] = "******";
            mockConfig["printxml"] = "false";
            mockConfig["timeout"] = "35";
            mockConfig["proxyHost"] = "www.mockproxy.com";
            mockConfig["merchantId"] = "MOCKID";
            mockConfig["password"] = "******";
            mockConfig["proxyPort"] = "3000";
            mockConfig["sftpUrl"] = "www.mockftp.com";
            mockConfig["sftpUsername"] = "******";
            mockConfig["sftpPassword"] = "******";
            mockConfig["knownHostsFile"] = "C:\\MockKnownHostsFile";
            mockConfig["onlineBatchUrl"] = "www.mockbatch.com";
            mockConfig["onlineBatchPort"] = "4000";
            mockConfig["requestDirectory"] = "C:\\MockRequests";
            mockConfig["responseDirectory"] = "C:\\MockResponses";

            rfrRequest = new RFRRequest(_memoryCache, mockConfig);

            Assert.AreEqual("C:\\MockRequests\\Requests\\", rfrRequest.getRequestDirectory());
            Assert.AreEqual("C:\\MockResponses\\Responses\\", rfrRequest.getResponseDirectory());

            Assert.NotNull(rfrRequest.getLitleTime());
            Assert.NotNull(rfrRequest.getLitleFile());
        }
 public void setUpBeforeTest()
 {
     rfrRequest = new RFRRequest(_memoryCache);
 }
Пример #11
0
        public void testRFRRequest()
        {
            var rfrRequest = new RFRRequest(_mockCache.Object);
            rfrRequest.litleSessionId = 123456789;

            var mockBatchXmlReader = new Mock<XmlReader>();
            mockBatchXmlReader.Setup(XmlReader => XmlReader.ReadState).Returns(ReadState.Closed);

            mockXmlReader.SetupSequence(XmlReader => XmlReader.ReadState)
                .Returns(ReadState.Interactive)
                .Returns(ReadState.Closed);
            mockXmlReader.Setup(XmlReader => XmlReader.ReadOuterXml())
                .Returns(
                    "<RFRResponse response=\"1\" message=\"The account update file is not ready yet. Please try again later.\" xmlns='http://www.litle.com/schema'> </RFRResponse>");

            var mockedLitleResponse = new litleResponse();
            mockedLitleResponse.setRfrResponseReader(mockXmlReader.Object);
            mockedLitleResponse.setBatchResponseReader(mockBatchXmlReader.Object);

            var mockLitleXmlSerializer = new Mock<litleXmlSerializer>();
            mockLitleXmlSerializer.Setup(
                litleXmlSerializer =>
                    litleXmlSerializer.DeserializeObjectFromString(It.IsAny<string>()))
                .Returns(mockedLitleResponse);
            var mockedLitleXmlSerializer = mockLitleXmlSerializer.Object;

            var mockedLitleFile = mockLitleFile.Object;
            var mockedLitleTime = mockLitleTime.Object;
            var mockedCommunications = mockCommunications.Object;

            litle.setLitleFile(mockedLitleFile);
            litle.setLitleTime(mockedLitleTime);
            litle.setCommunication(mockedCommunications);
            litle.setLitleXmlSerializer(mockedLitleXmlSerializer);

            rfrRequest.setLitleFile(mockedLitleFile);
            rfrRequest.setLitleTime(mockedLitleTime);

            litle.addRFRRequest(rfrRequest);

            var batchFileName = litle.sendToLitle();

            var actualLitleResponse = litle.receiveFromLitle(batchFileName);
            var nullLitleBatchResponse = actualLitleResponse.nextBatchResponse();
            var actualRFRResponse = actualLitleResponse.nextRFRResponse();
            var nullRFRResponse = actualLitleResponse.nextRFRResponse();

            Assert.IsNotNull(actualRFRResponse);
            Assert.AreEqual("1", actualRFRResponse.response);
            Assert.AreEqual("The account update file is not ready yet. Please try again later.",
                actualRFRResponse.message);
            Assert.IsNull(nullLitleBatchResponse);
            Assert.IsNull(nullRFRResponse);

            mockCommunications.Verify(
                Communications =>
                    Communications.FtpDropOff(It.IsAny<string>(), mockFileName, It.IsAny<Dictionary<string, string>>()));
            mockCommunications.Verify(
                Communications =>
                    Communications.FtpPickUp(It.IsAny<string>(), It.IsAny<Dictionary<string, string>>(), mockFileName));
        }
Пример #12
0
        public void RFRBatch()
        {
            batchRequest litleBatchRequest = new batchRequest();

            litleBatchRequest.id = "1234567A";

            accountUpdate accountUpdate1 = new accountUpdate();

            accountUpdate1.orderId = "1111";
            cardType card = new cardType();

            card.type           = methodOfPaymentTypeEnum.VI;
            card.number         = "4242424242424242";
            card.expDate        = "1210";
            accountUpdate1.card = card;

            litleBatchRequest.addAccountUpdate(accountUpdate1);

            accountUpdate accountUpdate2 = new accountUpdate();

            accountUpdate2.orderId = "1112";
            accountUpdate2.card    = card;

            litleBatchRequest.addAccountUpdate(accountUpdate2);

            litle.addBatch(litleBatchRequest);
            litleResponse litleResponse = litle.sendToLitleWithStream();

            Assert.NotNull(litleResponse);

            batchResponse litleBatchResponse = litleResponse.nextBatchResponse();

            Assert.NotNull(litleBatchResponse);
            while (litleBatchResponse != null)
            {
                accountUpdateResponse accountUpdateResponse = litleBatchResponse.nextAccountUpdateResponse();
                Assert.NotNull(accountUpdateResponse);
                while (accountUpdateResponse != null)
                {
                    Assert.AreEqual("000", accountUpdateResponse.response);

                    accountUpdateResponse = litleBatchResponse.nextAccountUpdateResponse();
                }
                litleBatchResponse = litleResponse.nextBatchResponse();
            }

            litleRequest litleRfr   = new litleRequest();
            RFRRequest   rfrRequest = new RFRRequest();
            accountUpdateFileRequestData accountUpdateFileRequestData = new accountUpdateFileRequestData();

            accountUpdateFileRequestData.merchantId = Properties.Settings.Default.merchantId;
            accountUpdateFileRequestData.postDay    = DateTime.Now;
            rfrRequest.accountUpdateFileRequestData = accountUpdateFileRequestData;

            litleRfr.addRFRRequest(rfrRequest);
            litleResponse litleRfrResponse = litleRfr.sendToLitleWithStream();

            Assert.NotNull(litleRfrResponse);

            RFRResponse rfrResponse = litleRfrResponse.nextRFRResponse();

            Assert.NotNull(rfrResponse);
            while (rfrResponse != null)
            {
                Assert.AreEqual("1", rfrResponse.response);
                Assert.AreEqual("The account update file is not ready yet.  Please try again later.", rfrResponse.message);

                rfrResponse = litleResponse.nextRFRResponse();
            }
        }
Пример #13
0
        public void RfrBatch()
        {
            var litleBatchRequest = new batchRequest {id = "1234567A"};

            var card = new cardType
            {
                type = methodOfPaymentTypeEnum.VI,
                number = "4242424242424242",
                expDate = "1210"
            };

            var accountUpdate1 = new accountUpdate
            {
                orderId = "1111",
                card = card
            };

            litleBatchRequest.addAccountUpdate(accountUpdate1);

            var accountUpdate2 = new accountUpdate
            {
                orderId = "1112",
                card = card
            };

            litleBatchRequest.addAccountUpdate(accountUpdate2);
            _litle.addBatch(litleBatchRequest);

            var batchName = _litle.sendToLitle();
            _litle.blockAndWaitForResponse(batchName, EstimatedResponseTime(0, 1 * 2));
            var litleResponse = _litle.receiveFromLitle(batchName);

            Assert.NotNull(litleResponse);

            var litleBatchResponse = litleResponse.nextBatchResponse();
            Assert.NotNull(litleBatchResponse);
            while (litleBatchResponse != null)
            {
                var accountUpdateResponse = litleBatchResponse.nextAccountUpdateResponse();
                Assert.NotNull(accountUpdateResponse);
                while (accountUpdateResponse != null)
                {
                    Assert.AreEqual("000", accountUpdateResponse.response);

                    accountUpdateResponse = litleBatchResponse.nextAccountUpdateResponse();
                }
                litleBatchResponse = litleResponse.nextBatchResponse();
            }

            var litleRfr = new litleRequest();
            var rfrRequest = new RFRRequest
            {
                accountUpdateFileRequestData = new accountUpdateFileRequestData
                {
                    merchantId = Properties.Settings.Default.merchantId,
                    postDay = DateTime.Now
                }
            };

            litleRfr.addRFRRequest(rfrRequest);

            var rfrBatchName = litleRfr.sendToLitle();

            try
            {
                _litle.blockAndWaitForResponse(rfrBatchName, 120000);
                var litleRfrResponse = _litle.receiveFromLitle(rfrBatchName);
                Assert.NotNull(litleRfrResponse);
                var rfrResponse = litleRfrResponse.nextRFRResponse();
                Assert.NotNull(rfrResponse);
                while (rfrResponse != null)
                {
                    Assert.AreEqual("1", rfrResponse.response);
                    Assert.AreEqual("The account update file is not ready yet.  Please try again later.", rfrResponse.message);
                    rfrResponse = litleResponse.nextRFRResponse();
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception handled <" + e.Message + ">");
            }
        }