Inheritance: transactionTypeWithReportGroup
        public void testActivate()
        {
            activate activate = new activate();
            activate.amount = 500;
            activate.orderSource = orderSourceType.ecommerce;
            activate.card = new cardType();

            batchRequest.addActivate(activate);

            Assert.AreEqual(1, batchRequest.getNumActivates());
            Assert.AreEqual(500, batchRequest.getActivateAmount());

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

            var mock = new Mock<Communications>();

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

            Communications mockedCommunication = mock.Object;
            litle.setCommunication(mockedCommunication);
            activateResponse activateResponse = litle.Activate(activate);
            Assert.AreEqual("123", activateResponse.litleTxnId);
        }
        public void testActivate_VirtualGiftCard()
        {
            activate activate = new activate();
            activate.orderId = "12345";
            activate.amount = 200;
            activate.orderSource = orderSourceType.ecommerce;
            activate.id = "theId";
            activate.reportGroup = "theReportGroup";
            activate.virtualGiftCard = new virtualGiftCardType();

            String actual = activate.Serialize();
            String expected = @"
            <activate id=""theId"" reportGroup=""theReportGroup"">
            <orderId>12345</orderId>
            <amount>200</amount>
            <orderSource>ecommerce</orderSource>
            <virtualGiftCard>
            </virtualGiftCard>
            </activate>";
            Assert.AreEqual(expected, actual);
        }
 public void addActivate(activate activate)
 {
     if (numAccountUpdates == 0)
     {
         numActivates++;
         activateAmount += activate.amount;
         tempBatchFilePath = saveElement(litleFile, litleTime, tempBatchFilePath, activate);
     }
     else
     {
         throw new LitleOnlineException(accountUpdateErrorMessage);
     }
 }
示例#5
0
        public void testActivate()
        {
            activate activate = new activate();
            activate.orderId = "theOrderId";
            activate.orderSource = orderSourceType.ecommerce;
            activate.card = new cardType();

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

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

            batchResponse mockLitleBatchResponse = new batchResponse();
            mockLitleBatchResponse.setActivateResponseReader(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.addActivate(activate);
            litleBatchRequest.addActivate(activate);
            litle.addBatch(litleBatchRequest);

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

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

            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 activateResponse Activate(activate activate)
        {
            litleOnlineRequest request = createLitleOnlineRequest();
            request.activate = activate;

            litleOnlineResponse response = sendToLitle(request);
            activateResponse activateResponse = response.activateResponse;
            return activateResponse;
        }