コード例 #1
0
        public LoadResponse Load(Load load)
        {
            LitleOnlineRequest request = CreateLitleOnlineRequest();
            request.Load = load;

            LitleOnlineResponse response = SendToLitle(request);
            return response.LoadResponse;
        }
        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);
        }
コード例 #3
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()
        {
            var load = new Load
            {
                OrderId = "12345",
                Amount = 200,
                OrderSource = OrderSourceType.Ecommerce,
                Card = new CardType(),
                ID = "theId",
                ReportGroup = "theReportGroup"
            };

            string actual = load.Serialize();
            const 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 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()));
        }
コード例 #6
0
 public void AddLoad(Load load)
 {
     if (_numAccountUpdates == 0)
     {
         _numLoads++;
         _loadAmount += load.Amount;
         _tempBatchFilePath = SaveElement(_litleFile, _litleTime, _tempBatchFilePath, load);
     }
     else
     {
         throw new LitleOnlineException(AccountUpdateErrorMessage);
     }
 }