Ejemplo n.º 1
0
        public void TestDeactivate()
        {
            var deactivate = new deactivate();

            deactivate.orderSource = orderSourceType.ecommerce;
            deactivate.card        = new cardType();

            _batchRequest.addDeactivate(deactivate);

            Assert.AreEqual(1, _batchRequest.getNumDeactivates());

            _mockLitleFile.Verify(litleFile => litleFile.createRandomFile(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>(), _mockLitleTime.Object));
            _mockLitleFile.Verify(litleFile => litleFile.AppendLineToFile(MockFilePath, deactivate.Serialize()));
        }
Ejemplo n.º 2
0
        public void TestDeactivate()
        {
            var deactivate = new deactivate();

            deactivate.orderSource = orderSourceType.ecommerce;
            deactivate.card        = new giftCardCardType();

            batchRequest.addDeactivate(deactivate);

            Assert.AreEqual(1, batchRequest.getNumDeactivates());

            mockCnpFile.Verify(cnpFile => cnpFile.createRandomFile(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>(), mockCnpTime.Object));
            mockCnpFile.Verify(cnpFile => cnpFile.AppendLineToFile(mockFilePath, deactivate.Serialize()));
        }
Ejemplo n.º 3
0
        public void testDeactivate()
        {
            var deactivate = new deactivate();
            deactivate.orderId = "theOrderId";
            deactivate.orderSource = orderSourceType.ecommerce;
            deactivate.card = new cardType();

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

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

            var mockLitleBatchResponse = new batchResponse();
            mockLitleBatchResponse.setDeactivateResponseReader(mockXmlReader.Object);

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

            mockLitleXmlSerializer.Setup(
                litleXmlSerializer =>
                    litleXmlSerializer.DeserializeObjectFromString(It.IsAny<string>()))
                .Returns(mockedLitleResponse);

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

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

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

            litle.setLitleTime(mockLitleTime.Object);

            var litleBatchRequest = new batchRequest(_mockCache.Object);
            litleBatchRequest.setLitleFile(mockedLitleFile);
            litleBatchRequest.setLitleTime(mockLitleTime.Object);
            litleBatchRequest.addDeactivate(deactivate);
            litleBatchRequest.addDeactivate(deactivate);
            litle.addBatch(litleBatchRequest);

            var batchFileName = litle.sendToLitle();
            var actualLitleResponse = litle.receiveFromLitle(batchFileName);
            var actualLitleBatchResponse = actualLitleResponse.nextBatchResponse();

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

            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));
        }