Inheritance: transactionTypeWithReportGroup
 public void addLoad(load load)
 {
     if (numAccountUpdates == 0)
     {
         numLoads++;
         loadAmount += load.amount;
         tempBatchFilePath = saveElement(litleFile, litleTime, tempBatchFilePath, load);
     }
     else
     {
         throw new LitleOnlineException(accountUpdateErrorMessage);
     }
 }
Esempio n. 2
0
        public void testLoad()
        {
            load load = new load();
            load.orderId = "theOrderId";
            load.orderSource = orderSourceType.ecommerce;
            load.card = new cardType();

            var mockLitleResponse = new Mock<litleResponse>();
            var mockLitleXmlSerializer = new Mock<litleXmlSerializer>();

            mockXmlReader.SetupSequence(XmlReader => XmlReader.ReadOuterXml())
                .Returns("<loadResponse xmlns=\"http://www.litle.com/schema\"><litleTxnId>123</litleTxnId></loadResponse>")
                .Returns("<loadResponse xmlns=\"http://www.litle.com/schema\"><litleTxnId>124</litleTxnId></loadResponse>");

            batchResponse mockLitleBatchResponse = new batchResponse();
            mockLitleBatchResponse.setLoadResponseReader(mockXmlReader.Object);

            mockLitleResponse.Setup(litleResponse => litleResponse.nextBatchResponse()).Returns(mockLitleBatchResponse);
            litleResponse mockedLitleResponse = mockLitleResponse.Object;

            mockLitleXmlSerializer.Setup(litleXmlSerializer => litleXmlSerializer.DeserializeObjectFromFile(It.IsAny<String>())).Returns(mockedLitleResponse);

            Communications mockedCommunication = mockCommunications.Object;
            litle.setCommunication(mockedCommunication);

            litleXmlSerializer mockedLitleXmlSerializer = mockLitleXmlSerializer.Object;
            litle.setLitleXmlSerializer(mockedLitleXmlSerializer);

            litleFile mockedLitleFile = mockLitleFile.Object;
            litle.setLitleFile(mockedLitleFile);

            litle.setLitleTime(mockLitleTime.Object);

            batchRequest litleBatchRequest = new batchRequest();
            litleBatchRequest.setLitleFile(mockedLitleFile);
            litleBatchRequest.setLitleTime(mockLitleTime.Object);
            litleBatchRequest.addLoad(load);
            litleBatchRequest.addLoad(load);
            litle.addBatch(litleBatchRequest);

            string batchFileName = litle.sendToLitle();
            litleResponse actualLitleResponse = litle.receiveFromLitle(batchFileName);
            batchResponse actualLitleBatchResponse = actualLitleResponse.nextBatchResponse();

            Assert.AreSame(mockLitleBatchResponse, actualLitleBatchResponse);
            Assert.AreEqual("123", actualLitleBatchResponse.nextLoadResponse().litleTxnId);
            Assert.AreEqual("124", actualLitleBatchResponse.nextLoadResponse().litleTxnId);
            Assert.IsNull(actualLitleBatchResponse.nextLoadResponse());

            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));
        }
        public void testLoad_OnlyRequired()
        {
            load load = new load();
            load.orderId = "12345";
            load.amount = 200;
            load.orderSource = orderSourceType.ecommerce;
            load.card = new cardType();
            load.id = "theId";
            load.reportGroup = "theReportGroup";

            String actual = load.Serialize();
            String expected = @"
            <load id=""theId"" reportGroup=""theReportGroup"">
            <orderId>12345</orderId>
            <amount>200</amount>
            <orderSource>ecommerce</orderSource>
            <card>
            <type>MC</type>
            </card>
            </load>";
            Assert.AreEqual(expected, actual);
        }
        public loadResponse Load(load load)
        {
            litleOnlineRequest request = createLitleOnlineRequest();
            request.load = load;

            litleOnlineResponse response = sendToLitle(request);
            loadResponse loadResponse = response.loadResponse;
            return loadResponse;
        }
        public void testLoad()
        {
            load load = new load();
            load.amount = 600;
            load.orderSource = orderSourceType.ecommerce;
            load.card = new cardType();

            batchRequest.addLoad(load);

            Assert.AreEqual(1, batchRequest.getNumLoads());
            Assert.AreEqual(600, batchRequest.getLoadAmount());

            mockLitleFile.Verify(litleFile => litleFile.createRandomFile(It.IsAny<String>(), It.IsAny<String>(), It.IsAny<String>(), mockLitleTime.Object));
            mockLitleFile.Verify(litleFile => litleFile.AppendLineToFile(mockFilePath, load.Serialize()));
        }
        public void testLoad()
        {
            load load = new load();
            load.orderId = "2";
            load.orderSource = orderSourceType.ecommerce;
            load.card = new cardType();

            var mock = new Mock<Communications>();

            mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*?<litleOnlineRequest.*?<load.*?<orderId>2</orderId>.*?</load>.*?", RegexOptions.Singleline), It.IsAny<Dictionary<String, String>>()))
                .Returns("<litleOnlineResponse version='8.21' response='0' message='Valid Format' xmlns='http://www.litle.com/schema'><loadResponse><litleTxnId>123</litleTxnId></loadResponse></litleOnlineResponse>");

            Communications mockedCommunication = mock.Object;
            litle.setCommunication(mockedCommunication);
            loadResponse loadResponse = litle.Load(load);
            Assert.AreEqual("123", loadResponse.litleTxnId);
        }