public ActivateResponse Activate(Activate activate)
        {
            LitleOnlineRequest request = CreateLitleOnlineRequest();
            request.Activate = activate;

            LitleOnlineResponse response = SendToLitle(request);
            return response.ActivateResponse;
        }
        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_Full()
        {
            var activate = new Activate
            {
                OrderId = "12345",
                Amount = 200,
                OrderSource = OrderSourceType.Ecommerce,
                ID = "theId",
                ReportGroup = "theReportGroup",
                Card = new CardType()
            };

            string actual = activate.Serialize();
            const string expected = @"
            <activate id=""theId"" reportGroup=""theReportGroup"">
            <orderId>12345</orderId>
            <amount>200</amount>
            <orderSource>ecommerce</orderSource>
            <card>
            <type>MC</type>
            </card>
            </activate>";
            Assert.AreEqual(expected, actual);
        }
        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 void AddActivate(Activate activate)
 {
     if (_numAccountUpdates == 0)
     {
         _numActivates++;
         _activateAmount += activate.Amount;
         _tempBatchFilePath = SaveElement(_litleFile, _litleTime, _tempBatchFilePath, activate);
     }
     else
     {
         throw new LitleOnlineException(AccountUpdateErrorMessage);
     }
 }